MCPcopy Create free account
hub / github.com/RedisGraph/redisgraph-go / AddEdge

Method AddEdge

graph.go:51–68  ·  view source on GitHub ↗

AddEdge adds an edge to the graph.

(e *Edge)

Source from the content-addressed store, hash-verified

49
50// AddEdge adds an edge to the graph.
51func (g *Graph) AddEdge(e *Edge) error {
52 // Verify that the edge has source and destination
53 if e.Source == nil || e.Destination == nil {
54 return fmt.Errorf("Both source and destination nodes should be defined")
55 }
56
57 // Verify that the edge's nodes have been previously added to the graph
58 if _, ok := g.Nodes[e.Source.Alias]; !ok {
59 return fmt.Errorf("Source node neeeds to be added to the graph first")
60 }
61 if _, ok := g.Nodes[e.Destination.Alias]; !ok {
62 return fmt.Errorf("Destination node neeeds to be added to the graph first")
63 }
64
65 e.graph = g
66 g.Edges = append(g.Edges, e)
67 return nil
68}
69
70// ExecutionPlan gets the execution plan for given query.
71func (g *Graph) ExecutionPlan(q string) (string, error) {

Callers 3

createGraphFunction · 0.80
TestQueryStatisticsFunction · 0.80
TestNodeMapDatatypeFunction · 0.80

Calls

no outgoing calls

Tested by 3

createGraphFunction · 0.64
TestQueryStatisticsFunction · 0.64
TestNodeMapDatatypeFunction · 0.64