트위터 네트워크 속성을 가져 오는 코드를 만들려고합니다.파이썬 네트워크 x를 사용하여 네트워크 속성 탐색
하지만 코드에 오류가 있습니다. 어떻게 된 건지 나는 모른다.
1000 1001
1000 1020191
1000 10267352
1000 10957902
1000 11039092
1000 1118691
1000 11882
1000 1228281
1000 1247041
1000 12965332
1000 13027572
1000 13075072
1000 13183162
1000 13250162
1000 13326292
1000 13452672
1000 13844892
1000 14061830
1000 1406481
1000 14134703
1000 14216951
1000 14254402
1000 14258044
1000 14270791
1000 14278978
1000 14313332
1000 14392970
1000 14441172
1000 14497568
1000 14502775
1000 14595635
1000 14620544
1000 14632615
1000 14680596
1000 14956164
1000 14998341
1000 15132211
1000 15145450
1000 15285998
1000 15288974
1000 15300187
1000 1532061
1000 15326300
"1000"추종자이며 :
import os, sys
import time
import networkx as nx
DG = nx.DiGraph()
ptime = time.time()
j = 1
#for line in open("./US_Health_Links.txt", 'r'):
for line in open("./test_network.txt", 'r'):
follower = line.strip().split('\t')[0]
followee = line.strip().split('\t')[1]
DG.add_edge(follower, followee)
if j%1000000 == 0:
print j*1.0/1000000, "million lines done", time.time() - ptime
ptime = time.time()
j += 1
print nx.number_connected_components(DG)
내가 몇 가지 링크이 같은 데이터를 수집 :
이Traceback (most recent call last):
File "Network_property.py", line 14, in <module>
followee = line.strip().split('\t')[1]
IndexError: list index out of range
코드는 이것이다 :
오류는 이것이다 다른 것은 followee입니다.
+
I 최대 연결된 기기의 노드 (2) 부분, 연결 컴포넌트 (1) 다수의 결과를 얻을 싶어 (3) 평균 인 과정, (4) 평균 중앙값 (5) 직경, (6) 클러스터링 계수
그러나 "networkx.lanl.gov"사이트는 작동하지 않습니다.
나를 도와주는 사람이 있습니까?
'test_network.txt'에 탭이 있는지 확인 하시겠습니까? 어쩌면'split ('\ t')'의 두 인스턴스를'split()'으로 바꾸고 어떤 일이 일어나는지 볼 수 있습니다. –
@DavidAlber 귀하의 의견이 대답이라면, 나는 그것을 upvote 줄 ... –
예, @DavidAlber 당신 말이 맞아! 감사! – ooozooo