0

我想使用python为现有图形找到这三个Prestige 度量

  1. 学位声望
  2. 邻近声望
  3. 等级声望

我可以为此目的使用networkx吗?如果没有,那么我可以使用哪个库以及我该怎么做。任何链接或参考表示赞赏。

4

2 回答 2

1

是的,你可以,但据我所知,你可以自己实施这些措施。
例如,考虑将度声望定义为节点的传入链接数除以传入链接的总可能数。

在这种情况下,您可以将其计算为:

n_nodes = 10
d = nx.gnp_random_graph(n_nodes, 0.5, directed=True)
degree_prestige = dict((v,len(d.in_edges(v))/(n_nodes-1)) for v in d.nodes_iter())

使用networkx定义的功能可以轻松实现的其他措施也是如此。

于 2018-08-28T22:37:41.627 回答
0
n_nodes = 5
d = nx.gnp_random_graph(n_nodes, 0.5, directed=True)

degree_prestige = dict((v,len(d.in_edges(v))/(n_nodes-1)) for v in d.nodes())
print("DEGREE PRESTIGE :\n")

for i in degree_prestige:
    print(i, " : ", degree_prestige[i])

distance = []

temp_dis = 0
n = 0
for dest in d.nodes:
    temp_dis = 0
    n = 0
    for src in d.nodes:
        if (nx.has_path(d,src,dest) == True):
            temp_dis = temp_dis + nx.shortest_path_length(d,source = src,target = dest)
            n = n + 1
    if temp_dis == 0:
        distance.append([dest, 0])
    else:
        distance.append([dest, temp_dis/(n - 1)])
print("\nPROXIMITY PRESTIGE :\n")
for i in distance:
    print(str(i[0]) + " : " + str(i[1]))

prominance = np.random.randint(1, 4, size=n_nodes)
print("\nASSUME PROMINANCE :\n")
print(prominance)
rank_prestige = np.zeros([n_nodes], dtype = int)

path_matrix = np.zeros([n_nodes, n_nodes], dtype = int)
i = 0
j = 0
for src in d.nodes:
    for dest in d.nodes:
        if d.has_edge(dest, src):
            path_matrix[i][j] = 1
        j = j+1
    j = 0
    i = i+1
for i in range(n_nodes):
    pr_i = 0
    for j in range(n_nodes):
        pr_i = pr_i + path_matrix[i][j] * prominance[j]
    rank_prestige[i] = pr_i

print("\nRANK PRESTIGE :\n")
print(rank_prestige)
于 2018-12-22T08:55:54.520 回答