page_rank(graph, algo = c("prpack", "arpack", "power"), vids = V(graph),
directed = TRUE, damping = 0.85, personalized = NULL, weights = NULL,
options = NULL)page_rank_old(graph, vids = V(graph), directed = TRUE, niter = 1000,
eps = 0.001, damping = 0.85, old = FALSE)
"prpack"
, which uses the PRPACK library
(https://github.com/dgleich/prpack). This is a new implementation in igraph
version 0.7, and the suggested one,NULL
. This argument can be used
to give edge weights for calculating the weighted PageRank of vertices. If
this is NULL
and the graph has a weight
edge attribute then
that is used. If weig
arpack
for details; or a named list to override the default
options for the power method (if algo="power"
). The default options
for thepage_rank
a named list with entries:arpack
for details. This entry is
NULL
if not the ARPACK implementation was used.page_rank_old
a numeric vector of Page Rank scores.Sergey Brin and Larry Page: The Anatomy of a Large-Scale Hypertextual Web Search Engine. Proceedings of the 7th World-Wide Web Conference, Brisbane, Australia, April 1998.
igraph 0.5 (and later) contains two PageRank calculation implementations.
The page_rank
function uses ARPACK to perform the calculation, see
also arpack
.
The page_rank_old
function performs a simple power method, this is
the implementation that was available under the name page_rank
in pre
0.5 igraph versions. Note that page_rank_old
has an argument called
old
. If this argument is FALSE
(the default), then the proper
PageRank algorithm is used, i.e. $(1-d)/n$ is added to the weighted
PageRank of vertices to calculate the next iteration. If this argument is
TRUE
then $(1-d)$ is added, just like in the PageRank paper;
$d$ is the damping factor, and $n$ is the total number of vertices.
A further difference is that the old implementation does not renormalize the
page rank vector after each iteration. Note that the old=FALSE
method is not stable, is does not necessarily converge to a fixed point. It
should be avoided for new code, it is only included for compatibility with
old igraph versions.
Please note that the PageRank of a given vertex depends on the PageRank of all other vertices, so even if you want to calculate the PageRank for only some of the vertices, all of them must be calculated. Requesting the PageRank for only some of the vertices does not result in any performance increase at all.
Since the calculation is an iterative process, the algorithm is stopped after a given count of iterations or if the PageRank value differences between iterations are less than a predefined value.
closeness
,
betweenness
, degree
g <- sample_gnp(20, 5/20, directed=TRUE)
page_rank(g)$vector
g2 <- make_star(10)
page_rank(g2)$vector
# Personalized PageRank
g3 <- make_ring(10)
page_rank(g3)$vector
reset <- seq(vcount(g3))
page_rank(g3, personalized=reset)$vector
Run the code above in your browser using DataCamp Workspace