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
dtekinoglu authored Apr 10, 2022
2 parents 9b243ae + 8aaac32 commit 7e63a65
Show file tree
Hide file tree
Showing 35 changed files with 3,965 additions and 0 deletions.
380 changes: 380 additions & 0 deletions 2022-round-1/29riyasaxena/nx_dev_test_output.txt

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions 2022-round-1/29riyasaxena/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#import libraries
import networkx as nx

#Digraph object
DG = nx.DiGraph()
DG.add_edges_from([(1, 2), (1, 3)]) # node 1,2,3 and connected them from 1->2->3
DG.add_edge("Hello", "World!") # node and connecting them "Hello" -> "World!"
DG.add_edge("World!", (5, 6)) # node (5,6) and connecting them "World!" -> (5,6)
DG.add_edge(1, (5, 6)) # edge 1 -> (5,6)
DG.add_edge(1, "World!") # edge 1 -> "World!"

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

# Calculate the shortest path and print it
sp = nx.shortest_path(DG)
print(sp)
1 change: 1 addition & 0 deletions 2022-round-1/29riyasaxena/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.2rc1.dev0
299 changes: 299 additions & 0 deletions 2022-round-1/Astroakanksha24/nx_dev_test_output.txt

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions 2022-round-1/Astroakanksha24/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Importing the libraries
import networkx as nx


# Creating DiGraph object
G = nx.DiGraph()

# Adding nodes of type int
G.add_node(24)
G.add_node(38)

# Adding nodes of type str
G.add_node("Amy")
G.add_node("Jake")
G.add_node("Rosa")
G.add_node("Gina")

# Adding edges to nodes
G.add_edges_from([("Gina","Rosa"),("Gina","Amy"),("Gina","Jake"),("Jake","Amy")]) # Gina-->Rosa | Gina-->Amy | Gina-->Jake | Jake-->Amy
G.add_edges_from([("Gina",24),("Jake",38)]) # Gina-->24 | Jake-->38
G.add_edge("Rosa",38) # Rosa-->38
G.add_edge(24,(16,17)) # 24-->(16,17)
G.add_edge("Rosa",(16,17)) # Rosa-->(16,17)

# Drawing the DiGraph
nx.draw(G, with_labels=True)

# Printing the number of nodes and edges
print("Number of Nodes:", G.number_of_nodes())
print("Number of Edges:", G.number_of_edges())

# Calculating the shortest path and printing it
shortest_path = nx.shortest_path(G)
print(shortest_path)
1 change: 1 addition & 0 deletions 2022-round-1/Astroakanksha24/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/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
1 change: 1 addition & 0 deletions 2022-round-1/Saumay1/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/aliveevie/nx_dev_test_output.txt

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions 2022-round-1/aliveevie/nx_notebook.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions 2022-round-1/aliveevie/nx_pull_requests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/aliveevie/networkx/pull/new/structured_labelled_array-4217
12 changes: 12 additions & 0 deletions 2022-round-1/aliveevie/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import networkx as nx
TG = nx.DiGraph()
TG.add_nodes_from([
(4, {"color": "red"}),
(5, {"color": "green"}),
(6, {"color": "blue"}),
(7, {"internship":"outreachy"}),
])
TG.add_edges_from([(4, 5), (6, 7)])
sp = dict(nx.all_pairs_shortest_path(TG))
nx.draw(TG)
sp
1 change: 1 addition & 0 deletions 2022-round-1/aliveevie/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
381 changes: 381 additions & 0 deletions 2022-round-1/anareyegen/nx_dev_test_output.txt

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions 2022-round-1/anareyegen/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import networkx as nx

DG = nx.DiGraph()

# Adding nodes
DG.add_node("a")
DG.add_node("t")
DG.add_node("w")
DG.add_node("f")
DG.add_node("o")
DG.add_node("q")
DG.add_node("e")


# Adding edges to nodes
DG.add_edges_from([("a","t"),("a","f"),("t","o"),("w","o"), ("f","t"), ("q","e")])
DG.add_edges_from([("a",4),("f",8), ("t", 2), ("w", 5), ("f", 7), ("q", 1)])
DG.add_edge("o", 10)
DG.add_edge("w",(1,7))

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

# Find and print the shortest path
shortest_path = nx.shortest_path(DG)
print(shortest_path)
print(list(DG.successors('a')))

# Output:
# print(shortest_path) {'a': {'a': ['a'], 't': ['a', 't'], 'f': ['a', 'f'], 4: ['a', 4],
# 'o': ['a', 't', 'o'], 2: ['a', 't', 2], 8: ['a', 'f', 8], 7: ['a', 'f', 7],
# 10: ['a', 't', 'o', 10]}, 't': {'t': ['t'], 'o': ['t', 'o'], 2: ['t', 2], 10: ['t', 'o', 10]},
# 'w': {'w': ['w'], 'o': ['w', 'o'], 5: ['w', 5], (1, 7): ['w', (1, 7)], 10: ['w', 'o', 10]},
# 'f': {'f': ['f'], 't': ['f', 't'], 8: ['f', 8], 7: ['f', 7], 'o': ['f', 't', 'o'],
# 2: ['f', 't', 2], 10: ['f', 't', 'o', 10]}, 'o': {'o': ['o'], 10: ['o', 10]},
# 'q': {'q': ['q'], 'e': ['q', 'e'], 1: ['q', 1]}, 'e': {'e': ['e']}, 4: {4: [4]},
# 8: {8: [8]}, 2: {2: [2]}, 5: {5: [5]}, 7: {7: [7]}, 1: {1: [1]}, 10: {10: [10]},
# (1, 7): {(1, 7): [(1, 7)]}}
# print(list(DG.successors('a'))): ['t', 'f', 4]
1 change: 1 addition & 0 deletions 2022-round-1/anareyegen/nx_version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.1
68 changes: 68 additions & 0 deletions 2022-round-1/deepthi1107/nx_tutorial_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/usr/bin/env python
# coding: utf-8

# In[1]:


#importing the required libraries
import networkx as nx


# In[2]:


#Creating DiGraph
graph1=nx.DiGraph()


# In[3]:


#adding node 11,"N1",1,2,3,(4,5)
graph1.add_node(11)
graph1.add_node("N1")
L=[1,2,3]
graph1.add_nodes_from(L)
graph1.add_node((4,5))


# In[4]:


#view of all the nodes inserted to the DiGraph
graph1.nodes()


# In[5]:


#adding edges 11->"N1",1->2,2->3,3->11,N1->(4,5),(4,5)->1
graph1.add_edge(11,"N1")
graph1.add_edge(1,2)
graph1.add_edge(2,3)
graph1.add_edge(3,11)
graph1.add_edge("N1",(4,5))
graph1.add_edge((4,5),1)


# In[6]:


#view of edges, connecting the nodes
graph1.edges()


# In[7]:


#visualization of DiGraph created
nx.draw(graph1,with_labels=1)


# In[8]:


#finding the shoretes path between the nodes and printing the shortest path
s_path = nx.shortest_path(graph1)
print(s_path)

Loading

0 comments on commit 7e63a65

Please sign in to comment.