2
$\begingroup$

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!

$\endgroup$
1
  • $\begingroup$ They are ordered by VertexIndex, i.e., 1, 2, 3, ... $\endgroup$
    – Bob Hanlon
    Jan 12, 2021 at 6:34

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.