From f367b0dc258ed06c748dad522f71a1aa15ba02be Mon Sep 17 00:00:00 2001 From: Khushi Gautam <65439761+khushishikhu@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:12:16 +0530 Subject: [PATCH] Create nx_tutorial_sctript.py #5 --- .../khushishikhu/nx_tutorial_sctript.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 2023-round-2/khushishikhu/nx_tutorial_sctript.py diff --git a/2023-round-2/khushishikhu/nx_tutorial_sctript.py b/2023-round-2/khushishikhu/nx_tutorial_sctript.py new file mode 100644 index 0000000..7b44c6e --- /dev/null +++ b/2023-round-2/khushishikhu/nx_tutorial_sctript.py @@ -0,0 +1,24 @@ +import networkx as nx +import matplotlib.pyplot as plt + +# networkx Digraph +G=nx.DiGraph() +# added an int node +G.add_node(8) +# added an str node +G.add_node('K') +# added a tuple +G.add_node(('k',2,7,'apple')) + +# connected them with distinct edges +G.add_edge(8,'K') +G.add_edge('k','K') +G.add_edge(8,2) +G.add_edge(2,7) +G.add_edge(2,'apple') +G.add_edge('K','apple') + + +nx.draw(G,with_labels=True) +shortestpath=nx.shortest_path(G) +print(shortestpath)