out_degreeはノードから出ていくエッジの数ということなので、無向グラフだからその属性が無いのではないでしょうか。in_degreeも同様ですね。
networkx.DiGraph.out_degree
あと、G.get_edge_dataが大文字になっていました。
以上を修正したのが下記です。
python3
1import networkx as nx
2import csv
3import pandas as pd
4
5# csvファイルの読み込み
6Data = open('test.csv', "r")
7next(Data, None) # CSVデータの最初の行をスキップ
8Graphtype = nx.Graph() # 無向グラフを定義
9
10G = nx.parse_edgelist(Data, delimiter=',', create_using=Graphtype,
11 nodetype=int, data=(('weight', float),))
12
13for x in G.nodes():
14 print ("Node:", x, "has total #degree:",G.degree(x))
15for u,v in G.edges():
16 print ("Weight of Edge ("+str(u)+","+str(v)+")", G.get_edge_data(u,v))
17
18nx.draw(G)
19plt.show()
20"""
21Node: 202 has total #degree: 1
22Node: 237 has total #degree: 1
23Node: 280 has total #degree: 1
24Node: 281 has total #degree: 1
25Node: 118 has total #degree: 2
26Node: 38 has total #degree: 9
27Node: 139 has total #degree: 9
28Node: 158 has total #degree: 9
29Node: 160 has total #degree: 11
30Node: 236 has total #degree: 9
31Node: 282 has total #degree: 11
32Node: 283 has total #degree: 9
33Node: 284 has total #degree: 9
34Node: 285 has total #degree: 9
35Node: 286 has total #degree: 9
36Node: 6 has total #degree: 3
37Node: 240 has total #degree: 3
38Weight of Edge (202,237) {'weight': 1.0}
39Weight of Edge (280,281) {'weight': 1.0}
40Weight of Edge (118,118) {'weight': 1.0}
41Weight of Edge (38,139) {'weight': 1.0}
42Weight of Edge (38,158) {'weight': 1.0}
43Weight of Edge (38,160) {'weight': 1.0}
44Weight of Edge (38,236) {'weight': 2.0}
45Weight of Edge (38,282) {'weight': 1.0}
46Weight of Edge (38,283) {'weight': 1.0}
47Weight of Edge (38,284) {'weight': 1.0}
48Weight of Edge (38,285) {'weight': 1.0}
49Weight of Edge (38,286) {'weight': 1.0}
50Weight of Edge (139,158) {'weight': 1.0}
51Weight of Edge (139,160) {'weight': 1.0}
52Weight of Edge (139,236) {'weight': 1.0}
53Weight of Edge (139,282) {'weight': 1.0}
54Weight of Edge (139,283) {'weight': 1.0}
55Weight of Edge (139,284) {'weight': 1.0}
56Weight of Edge (139,285) {'weight': 1.0}
57Weight of Edge (139,286) {'weight': 1.0}
58Weight of Edge (158,160) {'weight': 1.0}
59Weight of Edge (158,236) {'weight': 1.0}
60Weight of Edge (158,282) {'weight': 1.0}
61Weight of Edge (158,283) {'weight': 1.0}
62Weight of Edge (158,284) {'weight': 1.0}
63Weight of Edge (158,285) {'weight': 1.0}
64Weight of Edge (158,286) {'weight': 1.0}
65Weight of Edge (160,236) {'weight': 1.0}
66Weight of Edge (160,282) {'weight': 2.0}
67Weight of Edge (160,283) {'weight': 1.0}
68Weight of Edge (160,284) {'weight': 1.0}
69Weight of Edge (160,285) {'weight': 1.0}
70Weight of Edge (160,286) {'weight': 1.0}
71Weight of Edge (160,240) {'weight': 1.0}
72Weight of Edge (160,6) {'weight': 1.0}
73Weight of Edge (236,282) {'weight': 1.0}
74Weight of Edge (236,283) {'weight': 1.0}
75Weight of Edge (236,284) {'weight': 1.0}
76Weight of Edge (236,285) {'weight': 1.0}
77Weight of Edge (236,286) {'weight': 1.0}
78Weight of Edge (282,283) {'weight': 1.0}
79Weight of Edge (282,284) {'weight': 1.0}
80Weight of Edge (282,285) {'weight': 1.0}
81Weight of Edge (282,286) {'weight': 1.0}
82Weight of Edge (282,6) {'weight': 1.0}
83Weight of Edge (282,240) {'weight': 1.0}
84Weight of Edge (283,284) {'weight': 1.0}
85Weight of Edge (283,285) {'weight': 1.0}
86Weight of Edge (283,286) {'weight': 1.0}
87Weight of Edge (284,285) {'weight': 1.0}
88Weight of Edge (284,286) {'weight': 1.0}
89Weight of Edge (285,286) {'weight': 1.0}
90Weight of Edge (6,240) {'weight': 2.0}
91"""
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/07/23 03:14