python - Networkx degree method didn't produce want I think it is -
I have run the following script:
import import matpoltlib G. Ad_Age (1, 1, weight = 2), g.ed_ge (1, 3, weight = 2), g.ed_ge (1, 4, weight = 1) in the form of pyplot plt. Ad_age (1, 5, weight = 5) g.ad_age (2, 3, weight = 3) g.ad_age (2, 4, weight = 2) g.ed_ge (3, 5, weight = 4) d = g. Degree (1) Print GD [1] Print "Node 1 degree:", \ g. degree (1) print "weighted degree node 1:", \ g. Degree (1, weight = 'weight') nx.draw (g) plt.show () Output is:
{1: {' weight ': 2}, 3: {' weight ': 2}, 4: {' weight ': 1}, 5: {' weight ': 5}} weighted degree: 5 weighted degrees: 12 And the drawing is like this:
What's wrong with me? Since 4 nodes node 1 (including oneself) -Pass, why the degree 5 ? Since the total weight of the adjacent edges of node 1 is 10 (2 + 2 + 1 + 5), the degree method is produced 12 ? Thanks
For an indirect graph, adjacent corners of a peak Is equal to the number.
A special case is a loop , which adds two in the degree to its own connection to the loop edge of its own Can be understood from being understood as an adjacent head. In other words, a peak with a loop "sees" from the two ends of the edge as an adjacent head, thus, does not connect from two to one degree.
Comments
Post a Comment