Networkx PageRank - 不同权重的等级 [英] Networkx PageRank - Equal Ranks with Different Weights
问题描述
我有一个关于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}
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屋!