Create random graph schema Example: res = create_random_schema(redis_graph, {"N": 100, "M": 200}, { "R": {"source": "N", "target": "M", "count": 500}})
()
| 224 | |
| 225 | |
| 226 | def create_random_schema(): |
| 227 | """ |
| 228 | Create random graph schema |
| 229 | Example: |
| 230 | res = create_random_schema(redis_graph, {"N": 100, "M": 200}, { |
| 231 | "R": {"source": "N", "target": "M", "count": 500}}) |
| 232 | """ |
| 233 | nodes = [] |
| 234 | edges = [] |
| 235 | |
| 236 | labels_count = randint(1, 10) |
| 237 | for i in range(0, labels_count): |
| 238 | count = randint(10, 100) |
| 239 | properties = randint(0, 10) |
| 240 | labels = [f"N{i}"] |
| 241 | for j in range(0, randint(0, 5)): |
| 242 | l = randint(1, labels_count) |
| 243 | labels.append(f"N{l}") |
| 244 | |
| 245 | nodes.append( |
| 246 | {"count": count, "properties": properties, "labels": labels}) |
| 247 | |
| 248 | rel_types = randint(1, labels_count * 2) |
| 249 | for i in range(0, rel_types): |
| 250 | source_label = randint(0, labels_count - 1) |
| 251 | source_count = nodes[source_label]["count"] |
| 252 | target_label = randint(0, labels_count - 1) |
| 253 | target_count = nodes[target_label]["count"] |
| 254 | edge_count = randint(10, source_count * target_count) |
| 255 | edges.append({"type": f"R{i}", "source": source_label, |
| 256 | "target": target_label, "count": edge_count}) |
| 257 | |
| 258 | return nodes, edges |
| 259 | |
| 260 | |
| 261 | ALL_OPS = [create_node, create_edge, delete_node, |
no outgoing calls