图的节点之间的差异/分区,以计算Python中的中心度度量值

问题描述 投票:0回答:1

我正在使用networkx包来分析IMDb数据以计算中心度(紧密度和中间度)。问题是,图具有两种类型的节点-演员和电影。我只想计算相对于演员而不是总体图的中心性。The data(it is subset of the main data

代码-

T = nx.Graph()
T.add_nodes_from(demo_df.primaryName,bipartite=1)
T.add_nodes_from(demo_df.primaryTitle,bipartite=0)
T = nx.from_pandas_edgelist(demo_df,'primaryName','primaryTitle')
nx.closeness_centrality(T)
nx.betweenness_centrality(T)

我不希望它计算/显示电影(欲望之翼,Dopey Dicks,Studio Stoops)的中间和接近程度。我希望仅针对演员进行计算。

I don't want it to calculate/display the betweenness and closeness of the movies(Wings of Desire, Dopey Dicks, Studio Stoops). I want it to be calculated only for the actors.

python-3.x networkx imdb
1个回答
0
投票

对于二部图,您具有networkx.algorithms.bipartite.centrality副本。例如,对于networkx.algorithms.bipartite.centrality,结果将是以二度中心度为值的节点作为字典的键。在closeness_centrality参数中,指定一个二分节点集中的节点:

nodes
© www.soinside.com 2019 - 2024. All rights reserved.