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

Function create_graph

python/tests/test_graph_benchmarks.py:59–82  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

57
58
59def create_graph(n):
60 g = Graph()
61
62 props = [
63 {"name": "Laptop", "brand": "Dell", "ram": "16GB"},
64 {"title": "Inception", "director": "Christopher Nolan", "year": 2010},
65 {"city": "Paris", "country": "France", "population_millions": 2.1},
66 {"product": "Chair", "material": "Wood"},
67 {"animal": "Tiger", "habitat": "Forest", "endangered": True},
68 ]
69
70 for i in range(n):
71 shared_props = random.choice(props)
72 shared_meta = random.choice(props)
73
74 node = g.add_node(1, i, properties=shared_props)
75 node.add_metadata(shared_meta)
76
77 if i > 0:
78 j = random.randint(0, i - 1)
79 edge = g.add_edge(2, i, j, properties=shared_props)
80 edge.add_metadata(shared_meta)
81
82 return g
83
84
85@pytest.fixture(scope="function")

Callers 1

graphFunction · 0.70

Calls 4

GraphClass · 0.90
add_nodeMethod · 0.45
add_metadataMethod · 0.45
add_edgeMethod · 0.45

Tested by

no test coverage detected