MCPcopy Create free account
hub / github.com/microsoft/JARVIS / visialize_graph

Function visialize_graph

taskbench/visualize_graph.py:8–34  ·  view source on GitHub ↗
(data_dir)

Source from the content-addressed store, hash-verified

6@click.command()
7@click.option('--data_dir')
8def visialize_graph(data_dir):
9 graph_file = f"{data_dir}/graph_desc.json"
10 with open(graph_file, "r") as f:
11 data = json.load(f)
12
13 G = nx.DiGraph()
14
15 for node in data["nodes"]:
16 G.add_node(node["id"])
17
18 for link in data["links"]:
19 G.add_edge(link["source"], link["target"])
20
21 pos = nx.spring_layout(G)
22 pos = nx.random_layout(G)
23 pos = nx.kamada_kawai_layout(G)
24
25 # Show the visualization
26 plt.figure(figsize=(60, 60), dpi=80)
27 plt.tight_layout()
28 plt.axis("off")
29 plt.show()
30
31 nx.draw_networkx_nodes(G, pos, node_color="skyblue", node_size=1200)
32 nx.draw_networkx_edges(G, pos, arrows=True, arrowsize=40)
33 nx.draw_networkx_labels(G, pos, font_size=50, font_color="green", font_weight="bold")
34 plt.savefig(graph_file.replace(".json", ".pdf"))
35
36if __name__ == "__main__":
37 visialize_graph()

Callers 1

visualize_graph.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected