in graph/graph.go [72:86]
func (g *Graph[NT]) Connect(from, to NT) error {
fromNodeKey := from.GetName()
toNodeKey := to.GetName()
var ok bool
if from, ok = g.nodes[fromNodeKey]; !ok {
return NewGraphError(ErrConnectNotExistingNode, fmt.Sprintf("cannot connect node %s, it's not added in this graph yet", fromNodeKey))
}
if to, ok = g.nodes[toNodeKey]; !ok {
return NewGraphError(ErrConnectNotExistingNode, fmt.Sprintf("cannot connect node %s, it's not added in this graph yet", toNodeKey))
}
g.nodeEdges[fromNodeKey] = append(g.nodeEdges[fromNodeKey], &Edge[NT]{From: from, To: to})
return nil
}