Louvain_test_main.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:PhD 作者: wutaoadeny 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号