为什么 graphblas 返回的结果与 networkx 不同?

问题描述 投票:0回答:1

我正在尝试使用 graphblas 算法来加速使用 Python 的大型网络上的计算。不幸的是,即使对于非常简单的网络,graphblas 返回的结果也与网络算法给出的结果不同。这是一个最小的工作示例:

import networkx as nx
import graphblas_algorithms as ga

G = nx.DiGraph([(0, 1), (0, 2), (0, 3), (1, 2), (1, 3)])
nx.in_degree_centrality(G)
{0: 0.0, 1: 0.3333333333333333, 2: 0.6666666666666666, 3: 0.6666666666666666}

GG = ga.Graph.from_networkx(G)
ga.in_degree_centrality(GG)
0   1     2 3
1.0 0.666667  

我无法理解这个问题。有人知道我做错了什么吗?

我期望两者返回相同的结果,但显然不是。

python networkx
1个回答
0
投票

graphblas 中似乎存在错误,因为它的值是错误的。 来自networkx文档:

节点 v 的入度中心性是其传入边连接到的节点的分数。

将此定义应用于您的玩具示例:

0 : 0/3 = 0 # 0 incident edges, 3 other nodes in the network 
1 : 1/3 = 0.33
2 : 2/3 = 0.66
3 : 2/3 = 0.66

顺便说一句,graphblas 给出了“出度中心性”的正确值(尽管缺少所有值为 0 的键值对)。 这强烈表明 networkx.DiGraph 对象的转换或入度中心性计算中存在错误。

    

© www.soinside.com 2019 - 2024. All rights reserved.