MCPcopy Create free account
hub / github.com/Pometry/Raphtory / init_graph

Function init_graph

python/tests/test_search/test_index.py:6–59  ·  view source on GitHub ↗

Initializes the graph with nodes and properties.

(graph)

Source from the content-addressed store, hash-verified

4
5
6def init_graph(graph):
7 """Initializes the graph with nodes and properties."""
8
9 # Adding nodes with properties
10 graph.add_node(6, "N1", {"p1": 2}, "fire_nation")
11 graph.add_node(7, "N1", {"p1": 1}, "fire_nation")
12 graph.node("N1").add_metadata({"p1": 1})
13
14 graph.add_node(6, "N2", {"p1": 1}, "earth_kingdom")
15 graph.add_node(7, "N2", {"p1": 2}, "earth_kingdom")
16
17 graph.add_node(8, "N3", {"p1": 1}, "water_tribe")
18
19 graph.add_node(9, "N4", {"p1": 1}, "water_tribe")
20 graph.node("N4").add_metadata({"p1": 2})
21
22 graph.add_node(5, "N5", {"p1": 1}, "water_tribe")
23 graph.add_node(6, "N5", {"p1": 2}, "water_tribe")
24
25 graph.add_node(5, "N6", {"p1": 1}, "fire_nation")
26 graph.add_node(6, "N6", {"p1": 1}, "fire_nation")
27
28 graph.add_node(3, "N7", {"p1": 1}, "air_nomads")
29 graph.add_node(5, "N7", {"p1": 1}, "air_nomads")
30
31 graph.add_node(3, "N8", {"p1": 1}, "air_nomads")
32 graph.add_node(4, "N8", {"p1": 2}, "air_nomads")
33
34 graph.add_node(2, "N9", {"p1": 2}, "earth_kingdom")
35 graph.node("N9").add_metadata({"p1": 1})
36
37 graph.add_node(2, "N10", {"q1": 0}, "fire_nation")
38 graph.add_node(2, "N10", {"p1": 3}, "fire_nation")
39 graph.node("N10").add_metadata({"p1": 1})
40
41 graph.add_node(2, "N11", {"p1": 3}, "fire_nation")
42 graph.add_node(2, "N11", {"q1": 0}, "fire_nation")
43 graph.node("N11").add_metadata({"p1": 1})
44
45 graph.add_node(2, "N12", {"q1": 0}, "air_nomads")
46 graph.add_node(3, "N12", {"p1": 3}, "air_nomads")
47 graph.node("N12").add_metadata({"p1": 1})
48
49 graph.add_node(2, "N13", {"q1": 0}, "air_nomads")
50 graph.add_node(3, "N13", {"p1": 3}, "air_nomads")
51 graph.node("N13").add_metadata({"p1": 1})
52
53 graph.add_node(2, "N14", {"q1": 0}, "water_tribe")
54 graph.node("N14").add_metadata({"p1": 1})
55
56 graph.add_node(2, "N15", {}, "water_tribe") # NO_PROPS equivalent
57 graph.node("N15").add_metadata({"p1": 1})
58
59 return graph
60
61
62def search_nodes(graph, filter_expr, limit=20, offset=0):

Calls 3

add_nodeMethod · 0.45
add_metadataMethod · 0.45
nodeMethod · 0.45

Tested by

no test coverage detected