2017-07-11 00:17:18 +08:00
|
|
|
""" This file does nothing, it's just utilities for other setups """
|
|
|
|
|
2017-11-15 21:26:19 +08:00
|
|
|
from random import randint, seed
|
2017-07-11 00:17:18 +08:00
|
|
|
|
|
|
|
|
2017-07-11 23:45:34 +08:00
|
|
|
BATCH_SIZE = 100
|
2017-11-15 21:26:19 +08:00
|
|
|
seed(0)
|
2017-07-11 00:17:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
def create_vertices(vertex_count):
|
|
|
|
for vertex in range(vertex_count):
|
|
|
|
print("CREATE (:Label {id: %d})" % vertex)
|
2017-07-11 20:43:26 +08:00
|
|
|
if (vertex != 0 and vertex % BATCH_SIZE == 0) or \
|
|
|
|
(vertex + 1 == vertex_count):
|
2017-07-11 00:17:18 +08:00
|
|
|
print(";")
|
|
|
|
|
|
|
|
|
|
|
|
def create_edges(edge_count, vertex_count):
|
|
|
|
""" vertex_count is the number of already existing vertices in graph """
|
2017-07-11 23:45:34 +08:00
|
|
|
matches = []
|
|
|
|
merges = []
|
2017-07-11 00:17:18 +08:00
|
|
|
for edge in range(edge_count):
|
2017-07-30 22:22:25 +08:00
|
|
|
matches.append("MATCH (a%d :Label {id: %d}), (b%d :Label {id: %d})" %
|
2017-07-11 23:45:34 +08:00
|
|
|
(edge, randint(0, vertex_count - 1),
|
|
|
|
edge, randint(0, vertex_count - 1)))
|
|
|
|
merges.append("CREATE (a%d)-[:Type]->(b%d)" % (edge, edge))
|
|
|
|
if (edge != 0 and edge % BATCH_SIZE == 0) or \
|
|
|
|
((edge + 1) == edge_count):
|
|
|
|
print(" ".join(matches + merges))
|
|
|
|
print(";")
|
|
|
|
matches = []
|
|
|
|
merges = []
|