Skip to content

Instantly share code, notes, and snippets.

@pippellia-btc
Last active December 2, 2025 16:41
Show Gist options
  • Select an option

  • Save pippellia-btc/8642a25fcf535edcda1ddecd0bcd5f7b to your computer and use it in GitHub Desktop.

Select an option

Save pippellia-btc/8642a25fcf535edcda1ddecd0bcd5f7b to your computer and use it in GitHub Desktop.
How to display Pagerank by Vertex

Displaying pagerank is quite complex, since most end users don't know what it is and how it's defined.
Furthermore, Pagerank follows a power-law, which is inherently hard for humans to understand.

An easier way to understand the pagerank p of an entity is to display the % of the network it is part of. Something like "entity is part of the top 1%". However sometimes we wish to display the pagerank as a 0-100 score. The linear mapping $f(p) = 100p$ is really really poor to understand for humans.

Considering the power law model with exponent b and a graph of N nodes, the highest j-th node by pagerank has

$p(j) = \frac{(1-b)}{N} \cdot N^b \cdot j^{-b}$

by inverting the formula one get the position of a node with pagerank p

$j(p) = N \cdot (\frac{(1-b)}{Np})^{1/b}$

and the % of the network with pagerank lower than p is simply

$l(p) = \frac{N - j(p)}{N} = 1-(\frac{1-b}{Np})^{1/b}$

To remove the singularity in 0 we add to the denominator $(1-b)$

$F(p) = 1-(\frac{1-b}{Np + (1-b)})^{1/b}$

This way $F(0) = 0$

This is close, but the values are too skewed towards the high scores. We can lower the exponent to something like $a = 0.3$ or $a = 0.4$ to make them feel more "natural".

// Score returns a "natural" score from 0-100 given the following inputs:
// - pagerank: the pagerank of the entity
// - nodes: the number of nodes in the graph
export const Score = (pagerank, nodes) => {
  const b = 0.76
  const a = 0.38     // curvature control
  const C = 1 - b    // base constant

  const denom = nodes * pagerank + C
  const value = 1 - (C / denom) ** a
  return 100 * value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment