我想为一个具有6个节点的简单图计算中间度:
this.axios.post('Mycontroller/getCountByMonth',{
}).then((response) => {
this.dataMonth = response.data.dataMonth;
console.log('getList 2', this.dataMonth )
for (i = 0; i < this.dataMonth; i++) {
console.log('getList 3')
console.log(' >> ', this.dataMonth[i])
}
根据我为每个节点计算的结果应该是:
G=nx.Graph()
e=[(1,2),(1,5),(2,3),(3,6),(5,6),(4,2),(4,3)]
G.add_edges_from(e)
btw=nx.betweenness_centrality(G)
但是输出是:
{1: 1.5, 2: 2.5, 5: 1, 3: 2.5, 6: 1.5, 4: 0}
原因是什么?
答案 0 :(得分:2)
似乎您正在计算非标准化的中心度,而默认情况下,betweenness_centrality
将normalized
设置为True
。
相反,将其设置为False
:
G=nx.Graph()
e=[(1,2),(1,5),(2,3),(3,6),(5,6),(4,2),(4,3)]
G.add_edges_from(e)
btw=nx.betweenness_centrality(G, normalized=False)
# {1: 1.5, 2: 2.5, 5: 1.0, 3: 2.5, 6: 1.5, 4: 0.0}