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