Networkx PageRank - 不同权重的等级 [英] Networkx PageRank - Equal Ranks with Different Weights

查看:1252
本文介绍了Networkx PageRank - 不同权重的等级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于PageRank的问题,可能表明我不太了解它。如果我有一个带有两个节点A和B以及链接A→B权重1.0和B→权重2.0的图,那么不应该因为它的入度权重更高而使A的等级更高?



似乎情况并非如此,当我从networkx尝试PageRank但我不知道为什么。

 >>> from networkx import nx 
>>> DG = nx.DiGraph()
>>> DG.add_weighted_edges_from([(A,B,1.0),(B,A,2.0)])
>>> pr = nx.pagerank(DG)
>>> pr
{'A':0.5,'B':0.5}


解决方案

有向图的PageRank可以被认为是随机冲浪者在沿着有向边的几次随机跳跃之后的所有节点上的概率分布(通过随机隐形传送来解决断开和悬挂的节点) 。在每一跳中,随机冲浪者在特定边缘之后的概率是其权重除以离开当前节点的所有边上的权重之和。在你的例子中,每个节点上的随机冲浪者只有一个链接可以跳到另一个链接,因此无论你对这两个链接的权重如何,PageRank将永远给(0.5,0.5)。

I have a question about PageRank which may show that I don't understand it well. If I have a graph with two nodes "A" and "B" and the link A --> B weights 1.0 and B --> A weight 2.0, shouldn't A rank higher because its in-degree weights higher?

It seems that this is not the case when I try PageRank from networkx but I don't know why.

>>> from networkx import nx 
>>> DG = nx.DiGraph()
>>> DG.add_weighted_edges_from([("A", "B", 1.0),("B", "A",2.0)])
>>> pr = nx.pagerank(DG)
>>> pr
{'A': 0.5, 'B': 0.5}

解决方案

The PageRank of a directed graph can be thought of as the probability distribution over all nodes of where a random surfer will end up after several random hops along directed edges (with random teleportation to address disconnected and dangling nodes). At each hop, the probability of the random surfer following a specific edge is its weight divided by the sum of weights on all edges leaving the current node.

In your example, the random surfer at each node has only 1 link to follow to hop to the other, thus no matter what weights you put on those 2 links, PageRank will always give (0.5,0.5).

这篇关于Networkx PageRank - 不同权重的等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆