forked from hediet/vscode-debug-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
35 lines (29 loc) · 1.06 KB
/
graph.py
File metadata and controls
35 lines (29 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Install the python extension for VS Code
# (https:#marketplace.visualstudio.com/items?itemName=ms-python.python).
# The Debug Visualizer has no support for Python data extractors yet,
# so to visualize data, your value must be a valid JSON string representing the data.
# See readme for supported data schemas.
from json import dumps
from random import randint
graph = {
"kind": {"graph": True},
"nodes": [
{"id": "1", "label": "1"}
],
"edges": []
}
for i in range(2,100):
# add a node
id = str(i)
graph["nodes"].append({"id": id, "label": id})
# connects the node to a random edge
targetId = str(randint(1, i - 1))
graph["edges"].append({"from": id, "to": targetId})
print("i is " + str(i))
# try setting a breakpoint right above
# then put graph into the visualization console and press enter
# when you step through the code each time you hit the breakpoint
# the graph should automatically refresh!
# example of json_graph visualization with 10 nodes:
# https://i.imgur.com/RqZuYHH.png
print("finished")