Skip to content

Commit

Permalink
Merge branch 'networkx:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitadash authored Apr 2, 2022
2 parents b0b8330 + 3cef3e0 commit a04a27a
Show file tree
Hide file tree
Showing 9 changed files with 650 additions and 0 deletions.
1 change: 1 addition & 0 deletions 2022-round-1/Beatrice1d/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
35 changes: 35 additions & 0 deletions 2022-round-1/Lukong123/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python3

import networkx as nx
import matplotlib.pyplot as plt

# Create a NetworkX DiGraph graph object
DG = nx.DiGraph()

# Adding nodes of multiple type

# Adding nodes of type int (integer)
DG.add_nodes_from([1, 2, 3,])

# Adding nodes of type str (string)

DG.add_nodes_from(['smile', 'code', 'Consistency'])

# Adding nodes of type typle
DG.add_nodes_from([(5,6), (7, 8), (9, 10)])

# Adding multiple edges between nodes

DG.add_edges_from([(1, 'smile'), (2, 3), (3, (5, 6)),
('code', (7,8)), ('consistency', (9, 10)),
('smile', 3),((7,8), 3), ('consitency', 'smile'), (1, (5,6)),
((9, 10), 1)])

# Calculating shortest path between all pairs of node

path = dict(nx.all_pairs_shortest_path(DG))
print(path)

# plotting graph using networkx.draw

nx.draw(DG)
1 change: 1 addition & 0 deletions 2022-round-1/ManasviGoyal/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
267 changes: 267 additions & 0 deletions 2022-round-1/joyceannie/nx_dev_test_output.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions 2022-round-1/joyceannie/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
312 changes: 312 additions & 0 deletions 2022-round-1/peacelovingng/nx_dev_test_output.txt

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions 2022-round-1/peacelovingng/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Import the libraries
import networkx as nx
import matplotlib.pyplot as plt

# Create the DiGraph object
DG = nx.DiGraph()

# Add nodes/edges of type int
DG.add_node(1) # add an initial node 1
DG.add_edge(1, 2) # add an edge from 1 to 2

# Add nodes of type str
DG.add_node("alice") # add node "alice"
DG.add_node("bob") # add node "bob"

# Add nodes/edges of type tuple
DG.add_edge("bob", (3, 4)) # link "bob" to new nodes 3, 4
DG.add_edge(1, ("alice", "bob")) # add an edge from 1 to "alice" and "bob"
DG.add_edge(1, (4, 5)) # link node 1 to 3, 4
DG.add_edges_from([(5, 6), (6, 7)]) # add edges from 5, 6 to 7

# Print the number of nodes and edges
print("The number of nodes in DG:", DG.number_of_nodes())
print("The number of edges in DG:", DG.number_of_edges())

# Draw the DiGraph
nx.draw(DG, with_labels=True)

# Calculate and print out the shortest path in DG
sp = nx.shortest_path(DG)
print("The shortest path in DG: ", sp)
1 change: 1 addition & 0 deletions 2022-round-1/peacelovingng/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
1 change: 1 addition & 0 deletions 2022-round-1/singhmansi25/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1

0 comments on commit a04a27a

Please sign in to comment.