簡體   English   中英

網絡 X:考慮網絡指標中節點的權重,例如中介中心性

[英]Network X: Taking into consideration weight of nodes in network metrics such as betweenness centrality

我最近開始使用網絡 X 並遇到以下問題。

我有一個加權圖:

  • 這些節點具有不同的大小,因為它們代表在辦公室工作的人數。
  • 辦公室通過加權邊相互關聯,加權邊表示辦公室之間的距離(從一個部門到另一個部門需要多長時間)。

我想知道,復印機放在哪個辦公室(哪個節點)。 為了做到這一點,我想使用中介中心性和接近中心性的網絡指標。

問題:應用指標並不困難。 但是,它們只考慮邊緣的重量(距離),而不是辦公室工作的人數。 這當然要考慮到,否則復印機會放在一個辦公室里,這個辦公室離其他辦公室很近,而且有很多最短的路徑,但是所有旅行的人的總距離會太遠。

作為一種解決方案,我想將辦公室節點細分為代表員工的節點。 因此,在同一個辦公室工作的人與一個權重為零的邊鏈接(他們基本上是堆疊的),而每個員工也與其他辦公室的員工有鏈接。 基於這個新圖表,我現在可以計算指標。

但是,我不確定這在數學上是否正確,以及我現在如何將員工網絡指標轉換回辦公室網絡指標。

感謝你的幫助!

請在下面找到帶有代碼的示例:

概念在這里,您可以在括號中看到 5 個具有不同權重的節點。

 import networkx as nx #Generate example graph with 5 nodes G = nx.Graph() G.add_nodes_from([11,21,31,41,51]) #Office-graph G.add_edge(11,21, weight =3) G.add_edge(21,31, weight =2) G.add_edge(31,51, weight =4) G.add_edge(21,41, weight =1) G.add_edge(41,51, weight =5) nx.draw_networkx(G) #Calculate the weighted closeness centrality, CCW = nx.closeness_centrality(G, u=None, distance='weight', wf_improved=True) CCW #devide nodes into subnodes with weight of 1 G.add_node(22) G.add_node(23) G.add_node(24) G.add_node(32) G.add_node(52) #add respective edges G.add_edge(22,23, weight =0) G.add_edge(22,24, weight =0) G.add_edge(23,24, weight =0) G.add_edge(31,32, weight =0) G.add_edge(51,52, weight =0) G.add_edge(21,22, weight =3) G.add_edge(21,23, weight =3) G.add_edge(21,24, weight =3) G.add_edge(21,31, weight =2) G.add_edge(22,31, weight =2) G.add_edge(23,31, weight =2) G.add_edge(24,31, weight =2) G.add_edge(21,32, weight =2) G.add_edge(22,32, weight =2) G.add_edge(23,32, weight =2) G.add_edge(24,32, weight =2) G.add_edge(31,51, weight =4) G.add_edge(32,51, weight =4) G.add_edge(31,52, weight =4) G.add_edge(32,52, weight =4) G.add_edge(21,41, weight =1) G.add_edge(41,51, weight =5) G.add_edge(41,52, weight =5) nx.draw_networkx(G) #Calculate the weighted closeness centrality, CCW_new = nx.closeness_centrality(G, u=None, distance='weight', wf_improved=True) CCW1_new

正如我在上面的評論中所說,在我看來,您希望盡量減少到復印機的總距離。 鑒於圖表的性質,我傾向於一個簡單的蠻力解決方案。 這是我的方法:

import networkx as nx

from itertools import combinations

#Generate example graph with 5 nodes
G = nx.Graph()
G.add_nodes_from([11,21,31,41,51])

#Office-graph
G.add_edge(11,21, weight=3)
G.add_edge(21,31, weight=2)
G.add_edge(31,51, weight=4)
G.add_edge(21,41, weight=1)
G.add_edge(41,51, weight=5)

# let's make sure we know the correct answer by assigning one office 99% of the workforce
office_to_people = {11: 5, 21: 2, 31: 1000, 41:0, 51:10}

node_to_cost = {ii : 0 for ii in G.nodes}
for source, target in combinations(list(G.nodes), 2):
    path_length = nx.shortest_path_length(G, source, target, weight='weight')
    node_to_cost[source] += office_to_people[target] * path_length
    node_to_cost[target] += office_to_people[source] * path_length

office, minimum_cost = sorted(node_to_cost.items(), key=lambda x: x[1])[0]
print(f"{office}")
# 31 

如果您想考慮不均勻的復印機使用,則可以通過簡單地計算每個辦公室的復印機總使用量並將office_to_people替換為等效的office_to_total_use來輕松擴展此方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM