ldp_fea.py 文件源码

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

项目:academic 作者: xinchrome 项目源码 文件源码
def authorNet_feature():
    # output: compute the author centrialy for each author
    #         author centrality dict
    authorCo = pickle.load(open(cspath+"coauthor","rb")) #
    nodeSet = set()
    edgeSet = set()
    for key,val in authorCo.iteritems():
        nodeSet.add(key)
        edgeSet.update([(key,item) for item in val if item!=key])
    pickle.dump(nodeSet,open(cspath+"co_nodeSet","wb"))
    pickle.dump(edgeSet,open(cspath+"co_edgeSet","wb"))
    g = nx.Graph()
    g.add_nodes_from(nodeSet)
    g.add_edges_from(edgeSet)
    interested_node = None

    clo_cen = defaultdict(int)
    for node in g.nodes():
        clo_cen[node]=1

    # Closeness centrality
    #clo_cen = nx.betweenness_centrality(g, k=int(len(g.nodes())/5))
    #centrality is time-consuming, denote this in real atmosphere
    pickle.dump(clo_cen,open(cspath+"author_cen","wb"))
    print 'authorNet_feature finish'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号