PageIndexVSRag / visualize.py
Pranesh64's picture
init: added files to hf
77d2ccf verified
raw
history blame contribute delete
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()