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'
评论列表
文章目录