TransWikia.com

Confusion about ordering in output of PageRankCentrality

Mathematica Asked by HotelTrivago on February 6, 2021

I’m doing a project in which I want to rank the nodes of a graph using page-rank centrality. The Mathematica documentation for PageRankCentrality is:

PageRankCentrality[g, α], gives a list of page-rank centralities for the vertices in the graph g and weight α.

For example, it may return something like: {0.04, 0.0012, 0.093}, where each element of the list is a centrality measure. My question is how do I figure out which nodes each of these centrality measures represents? In other words, how would I figure out if node 1, 2, or 3 is the node that corresponds to 0.04, 0.0012, or 0.093?

Thank you so much!

One Answer

All functions that returns values that characterize vertices return them in the same order as VertexList.

If you want to get an association between vertices and centralities, you could use something similar to

g = Graph[{2 <-> 1, 3 <-> 2}];

AssociationThread[
 VertexList[g],
 BetweennessCentrality[g]
 ]

As you can see here, the vertex names (which happen to be integers here) are not the same as the vertex indices, i.e. the position of vertices in VertexList.

Answered by Szabolcs on February 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP