def GetGmlSubG():
'read Data'
Gt=nx.Graph()
fedge = fname + '.edge'
try:
fdobj = open(fedge,'r')
except IOError as e:
print "***file open error:",e
else:
s = 'source' #s = 'source '
tepstr = ''
Result = []
eline = fdobj.readline()
while eline:
if s in eline:
source = eline[11:]
source = source.strip('\n')
tline = fdobj.readline()
target = tline[11:]
target = target.strip('\n')
tep = (source,target)
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
评论列表
文章目录