iをフィレンツェの家族グラフ用間隔度中心性計算:ノードvのnetworkxにおけるbetweenness_centrality(...)の説明から媒介中心:論理エラー
import networkx as nx
# build up a graph
G = nx.florentine_families_graph()
bw_centrality = nx.betweenness_centrality(G, normalized=False)
抜粋、
媒介中心でありますvを通過する全対最短経路の割合の和:
したがって、betweenness centr alityは1
より小さくする必要があります。しかし、私は結果を得た:(赤ノードの媒介中心、メディチ '、47.5
ある)
Iは次のように媒介中心が計算方法を、
node_and_times = dict.fromkeys(G.nodes(), 0) # a dict of node : the number of shortest path passing through node
sum_paths = 0
for s, t in itertools.product(G.nodes(), repeat=2): # all pair of nodes <s, t>
paths = nx.all_shortest_paths(G, s, t) # generator of lists
for path in paths:
sum_paths += 1
# stats nodes passing through shortest path
for node in path[1:-1]: # intermediate nodes
node_and_times[node] += 1
bw_centrality = {k : v*1.0/sum_paths for k, v in node_and_times.items()}
を
と私は、次の結果を得た、
私はそうですか? normalized=False
を削除
回答で述べたように、私の計算と一致しない、次の結果を得ました。
'answerersで述べたように、normalized = Falseを削除すると、計算結果と一致しない次の結果が得られました。あなたの計算が間違っているので、それは間の重心を計算していません。 –
@TonyBabarinoあなたは正しいです。私は、「最短経路の総数」に対する「vを通る最短経路の数」の比率としての中間度の定義を誤解しています。 – SparkAndShine
まあまあです。私は答えでそれを計算する方法を説明しようとした、私はあなたが私の説明を理解することを願っています。乾杯! –