I ran the following script:
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
G.add_edge(1, 1, weight=2)
G.add_edge(1, 3, weight=2)
G.add_edge(1, 4, weight=1)
G.add_edge(1, 5, weight=5)
G.add_edge(2, 3, weight=3)
G.add_edge(2, 4, weight=2)
G.add_edge(3, 5, weight=4)
d = G.degree(1)
print G.edge[1]
print "Degree of node 1:", \
G.degree(1)
print "Weighted degree of node 1:", \
G.degree(1, weight='weight')
nx.draw(G)
plt.show()
Conclusion:
{1: {'weight': 2}, 3: {'weight': 2}, 4: {'weight': 1}, 5: {'weight': 5}}
Weighted degree: 5
Weighted degree: 12
And the picture looks like this:

What bothers me:
Since there are nodes 4 adjacent to node 1 (including itself), why is degree 5 ?
Since the total weight of neighboring edges of node 1 is 10 (2 + 2 + 1 + 5), why is the method of degree 12
thank
source
share