source/projects/datalog/make_graph.py

26 lines
520 B
Python
Raw Normal View History

2021-05-15 05:39:18 +00:00
"""
For benchmarking the datalog.
Generates a large graph, which will be expensive to enumerate 2-edges over and paths through.
"""
from random import choice
from uuid import uuid4 as uuid
with open("graph.dtl", "w") as f:
2021-05-15 17:34:32 +00:00
nodes = []
2021-05-15 05:39:18 +00:00
2021-05-15 17:34:32 +00:00
# Generate 10k edges
for i in range(10000):
if nodes:
from_node = choice(nodes)
else:
from_node = uuid()
2021-05-15 05:39:18 +00:00
2021-05-15 17:34:32 +00:00
to_node = uuid()
2021-05-15 05:39:18 +00:00
2021-05-15 17:34:32 +00:00
nodes.append(to_node)
2021-05-15 05:39:18 +00:00
2021-05-15 17:34:32 +00:00
f.write(f"edge({str(from_node)!r}, {str(to_node)!r}).\n")