复杂网络节点重要性算法之局部中心性

介数中心性和接近中心性指标,  虽然具有较好的刻画节点重要性的能力,  但计算复杂度太高,  难以在大规模网络上使用.  为了权衡算法的效率和效果,  Chen 等人提出了一种基于半局部信息的节点重要性排序方法, 简称半局部中心性(semi-local  centrality).  首先定义N(w)为节点Vw的两层邻居度,其值等于从 Vw出发 2步内可到达的邻居的数目,  然后定义

其中 表示节点 vj的一阶邻居节点的集合.  最终节点 vi的局部中心性定义为  

可见,  半局部中心性涉及了节点的四阶邻居信息. 

#%%
import networkx as nx
#定义图的节点和边 
nodes=['1','2','3','4','5','6','7','8','9','10','11',
       '12','13','14','15','16','17','18','19','20',
       '21','22','23'] 
edges=[('1','2',1),('1','3',1),('1','4',1),('1','5',1),
       ('1','6',1),('1','7',1),('1','8',1),('1','9',1),
       ('2','3',1),('3','4',1),('6','10',1),('7','8',1),
       ('8','9',1),('10','11',1),('10','23',1),('11','12',1),
       ('11','21',1),('11','23',1),('12','13',1),('12','14',1),
       ('12','15',1),('13','14',1),('13','15',1),('13','22',1),('14','15',1),
       ('14','23',1),('15','16',1),('16','17',1),('16','18',1),
       ('16','22',1),('17','18',1),('17','20',1),('17','21',1),
       ('18','19',1),('18','22',1),('19','20',1),('19','21',1),
       ('20','21',1),('20','23',1),('22','23',1)] 
#%%
#定义无向图 
G = nx.Graph()
 
#往图添加节点和边 
G.add_nodes_from(nodes)
G.add_weighted_edges_from(edges) 
#%%
N = {}
Q = {}
CL = {}
for node in G.node:
    node_nei = list(G.neighbors(node))
    for n_i in node_nei:
        node_nei = node_nei + list(G.neighbors(n_i))
    node_nei = list(set(node_nei))
    N[node] = len(node_nei)-1

for node in G.node:
    node_nei = list(G.neighbors(node))
    t = 0
    for n_i in node_nei:
        t = t + N[n_i]
    Q[node] = t
    
for node in G.node:
    node_nei = list(G.neighbors(node))
    t = 0
    for n_i in node_nei:
        t = t + Q[n_i]
    CL[node] = t

for node in G.node:
    print(node,'N-value:',N[node],'Q-value:',Q[node],'CL-value:',CL[node])

结果: 

1 N-value: 9 Q-value: 67 CL-value: 145
2 N-value: 8 Q-value: 17 CL-value: 92
3 N-value: 8 Q-value: 25 CL-value: 101
4 N-value: 8 Q-value: 17 CL-value: 92
5 N-value: 8 Q-value: 9 CL-value: 67
6 N-value: 11 Q-value: 18 CL-value: 104
7 N-value: 8 Q-value: 17 CL-value: 92
8 N-value: 8 Q-value: 25 CL-value: 101
9 N-value: 8 Q-value: 17 CL-value: 92
10 N-value: 9 Q-value: 37 CL-value: 111
11 N-value: 12 Q-value: 41 CL-value: 166
12 N-value: 9 Q-value: 38 CL-value: 157
13 N-value: 8 Q-value: 39 CL-value: 157
14 N-value: 9 Q-value: 40 CL-value: 166
15 N-value: 9 Q-value: 37 CL-value: 156
16 N-value: 11 Q-value: 39 CL-value: 158
17 N-value: 9 Q-value: 39 CL-value: 158
18 N-value: 9 Q-value: 40 CL-value: 148
19 N-value: 8 Q-value: 28 CL-value: 119
20 N-value: 10 Q-value: 40 CL-value: 158
21 N-value: 9 Q-value: 39 CL-value: 148
22 N-value: 12 Q-value: 42 CL-value: 170
23 N-value: 14 Q-value: 52 CL-value: 200

参考:

Duanbing Chen, Linyuan Lü, Ming-Sheng Shang, et al. Identifying influential nodes in complex networks[J]. Physica A: Statistical Mechanics and its Applications, 2012, 391(4):1777-1787.

任晓龙, 吕琳媛. 网络重要节点排序方法综述[J]. 科学通报, 2014(13):1175-1197.

http://www.xiaowangyun.com/wyblog/detail/?id=121

 

 

你可能感兴趣的:(网络,网络分析,NetworkX)