Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a python script #5 #258

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 2023-round-2/tiwavaldese/nx_pull_requests.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
https://github.com/networkx/outreachy/pull/251

https://github.com/networkx/outreachy/pull/257
41 changes: 41 additions & 0 deletions 2023-round-2/tiwavaldese/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import networkx as nx
import matplotlib.pyplot as plt

#Create a DiGraph graph object
G = nx.DiGraph()

#Add multiple nodes of different types
G.add_node(1)
G.add_nodes_from([2,3])
G.add_node(4)
G.add_node(5)
G.add_node(6)
G.add_nodes_from("spam")

#Add multiple edges between nodes
G.add_edge(1,(2,3))
G.add_edge((2,3),1)
G.add_edge(1,3)
G.add_edge(3,1)
G.add_edge((2,3),5)
G.add_edge(5,(2,3))
G.add_edge((2,3),6)
G.add_edge(6,(2,3))
G.add_edge(4,5)
G.add_edge(5,4)
G.add_edge(4,'s')
G.add_edge('s',4)
G.add_edge(5,'p')
G.add_edge('p',5)
G.add_edge('a',6)
G.add_edge(6,'a')
G.add_edge(2,'m')
G.add_edge('m',2)

# Find the shortest path and print
st_p = nx.shortest_path(G)
print(st_p)

# Plot the Graph
nx.draw(G, with_labels = True, node_color= 'red')
plt.show()