Spaces:
Runtime error
Runtime error
Download visualize.py from Pranesh64/PageIndexVSRag: direct link, hf CLI and curl.
- Browser
- Download file 482 Bytes
-
https://huggingface.co/spaces/Pranesh64/PageIndexVSRag/resolve/main/visualize.py
- Command line
-
hf download hf://spaces/Pranesh64/PageIndexVSRag/visualize.py
-
curl -L -o visualize.py https://huggingface.co/spaces/Pranesh64/PageIndexVSRag/resolve/main/visualize.py
482 Bytes
| # visualize.py | |
| import networkx as nx | |
| import matplotlib.pyplot as plt | |
| def draw_tree(tree): | |
| G = nx.DiGraph() | |
| def traverse(node, parent=None): | |
| G.add_node(node["title"]) | |
| if parent: | |
| G.add_edge(parent, node["title"]) | |
| for child in node.get("children", []): | |
| traverse(child, node["title"]) | |
| traverse(tree) | |
| pos = nx.spring_layout(G) | |
| nx.draw(G, pos, with_labels=True, node_size=2000) | |
| plt.show() |