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

Function createGraph

client_test.go:13–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11var graph Graph
12
13func createGraph() {
14 conn, _ := redis.Dial("tcp", "0.0.0.0:6379")
15 conn.Do("FLUSHALL")
16 graph = GraphNew("social", conn)
17
18 // Create 2 nodes connect via a single edge.
19 japan := NodeNew("Country", "j", nil)
20 john := NodeNew("Person", "p", nil)
21 edge := EdgeNew("Visited", john, japan, nil)
22
23 // Set node properties.
24 john.SetProperty("name", "John Doe")
25 john.SetProperty("age", 33)
26 john.SetProperty("gender", "male")
27 john.SetProperty("status", "single")
28
29 japan.SetProperty("name", "Japan")
30 japan.SetProperty("population", 126800000)
31
32 edge.SetProperty("year", 2017)
33
34 // Introduce entities to graph.
35 graph.AddNode(john)
36 graph.AddNode(japan)
37 graph.AddEdge(edge)
38
39 // Flush graph to DB.
40 _, err := graph.Commit()
41 if err != nil {
42 panic(err)
43 }
44}
45
46func setup() {
47 createGraph()

Callers 4

setupFunction · 0.85
TestMapFunction · 0.85
TestPathFunction · 0.85
TestParameterizedQueryFunction · 0.85

Calls 7

GraphNewFunction · 0.85
NodeNewFunction · 0.85
EdgeNewFunction · 0.85
AddNodeMethod · 0.80
AddEdgeMethod · 0.80
CommitMethod · 0.80
SetPropertyMethod · 0.45

Tested by

no test coverage detected