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 8c8995a

Browse files
Update Chapter 2 - Important nodes.py
1 parent 72877d8 commit 8c8995a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎Network Analysis in Python (Part 1)/Chapter 2 - Important nodes.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def nodes_with_m_nbrs(G, m):
1515
for n in G.nodes():
1616

1717
# Check if the number of neighbors of n matches m
18-
if len(G.neighbors(n)) == m:
18+
if len(list(G.neighbors(n))) == m:
1919

2020
# Add the node n to the set
2121
nodes.add(n)
@@ -31,7 +31,7 @@ def nodes_with_m_nbrs(G, m):
3131
#---------=======================================================--------------%
3232
#Compute degree distribution
3333
# Compute the degree of every node: degrees
34-
degrees = [len(T.neighbors(n)) for n in T.nodes()]
34+
degrees = [len(list(T.neighbors(n))) for n in T.nodes()]
3535

3636
# Print the degrees
3737
print(degrees)
@@ -249,4 +249,4 @@ def find_node_with_highest_bet_cent(G):
249249

250250

251251

252-
#---------=======================================================--------------%
252+
#---------=======================================================--------------%

0 commit comments

Comments
(0)

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