def GetTxtSubG():
'read Data'
Gt=nx.Graph()
try:
fdobj = open(fname,'r')
except IOError as e:
print "***file open error:",e
else:
tepstr = ''
Result = []
eline = fdobj.readline()
while eline:
line = eline.strip().split()
#self.G.add_edge(line[0],line[1])
tep = (line[0],line[1])
Result.append(tep)
eline = fdobj.readline()
#print Result
Gt.add_edges_from(Result)
graphs = nx.connected_component_subgraphs(Gt)
SubG = graphs[0].edges()
return SubG
评论列表
文章目录