Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f6208c4

Browse files
Merge pull request #6 from shadab-entrepreneur/patch-2
Update Chapter 4 - Bringing it all together.py
2 parents c7bcf28 + 440b4b2 commit f6208c4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎Network Analysis in Python (Part 1)/Chapter 4 - Bringing it all together.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@
140140
# Import necessary modules
141141
from nxviz import ArcPlot
142142
import matplotlib.pyplot as plt
143-
143+
144144
# Identify the largest maximal clique: largest_max_clique
145145
largest_max_clique = set(sorted(nx.find_cliques(G), key=lambda x: len(x))[-1])
146146

147147
# Create a subgraph from the largest_max_clique: G_lmc
148-
G_lmc = G.subgraph(largest_max_clique)
148+
G_lmc = G.subgraph(largest_max_clique).copy()
149149

150150
# Go out 1 degree of separation
151-
for node in G_lmc.nodes():
151+
for node in list(G_lmc.nodes()):
152152
G_lmc.add_nodes_from(G.neighbors(node))
153-
G_lmc.add_edges_from(zip([node]*len(G.neighbors(node)), G.neighbors(node)))
153+
G_lmc.add_edges_from(zip([node]*len(list(G.neighbors(node))), G.neighbors(node)))
154154

155155
# Record each node's degree centrality score
156156
for n in G_lmc.nodes():
@@ -209,4 +209,4 @@
209209

210210

211211

212-
#---------=======================================================--------------%
212+
#---------=======================================================--------------%

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /