问题
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}
回答1:
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).
来源:https://stackoverflow.com/questions/15962324/networkx-pagerank-equal-ranks-with-different-weights