Skip to contents

R6 class to manage personalized pagerank calculations

R6 class to manage personalized pagerank calculations

Public fields

seeds

A character vector of the seed nodes.

path

A character vector of nodes whose neighborhoods we examined.

stats

A tibble::tibble() with one row for each visited node and the following columns:

  • name: Name of a node (character).

  • r: Current estimate of residual per out-degree for a node.

  • p: Current estimate of the pagerank for a node.

  • in_degree: Number of incoming edges to a node.

  • out_degree: Number of outcoming edges from a node.

failed

A character vector of nodes that could not be visited.

graph

An abstract graph object.

alpha

Teleportation constant from Algorithm 3.

alpha_prime

Transformed teleportation constant from Algorithm 3.

epsilon

Error tolerance.

max_visits

Maximum number of nodes to visit before terminating.

tau

Regularization parameter used in Algorithm 4.

Methods


Method new()

Create a new Tracker object.

Usage

Tracker$new(graph, alpha, epsilon, tau, max_visits)

Arguments

graph

See appr().

alpha

See appr().

epsilon

See appr().

tau

See appr().

max_visits

See appr().

Returns

A new Tracker object.


Method print()

Print the tibble containing the current state of the pagerank calculation.

Usage

Tracker$print()


Method remaining()

Determine nodes that need to be visited. Note that, if there is a node with zero out degree, you will never leave from that node. So it is important to make sure we never add nodes with zero out degree into the tracker.

Usage

Tracker$remaining()

Returns

A character vector of node names with current residuals greater than epsilon.


Method current_approximation_error()

Determine current quality of approximation.

Usage

Tracker$current_approximation_error()

Returns

A numeric vector of length one with the current worst error bound.


Method in_tracker()

Check if there is already a row for a particular node

Usage

Tracker$in_tracker(nodes)

Arguments

nodes

Character name of node(s) in the graph.

Returns

TRUE if there is a row for node, FALSE if there is not a row for node.


Method in_failed()

Check if we previously failed to visit a node

Usage

Tracker$in_failed(node)

Arguments

node

Character name of a node in the graph.

Returns

TRUE if we failed to visit node, FALSE otherwise. Note that this function will return FALSE if node is new and we haven't seen it before.


Method add_seed()

Create an entry for node in the tracker. Assumes that node is not in the tracker yet, and does not check if this is the case.

Usage

Tracker$add_seed(seeds, preference)

Arguments

seeds

The name of the node in the graph as a length 1 character vector.

preference

TODO: recall what on earth this is.


Method add_to_path()

TODO

Usage

Tracker$add_to_path(node)

Arguments

node

The name of the node in the graph as a length 1 character vector.


Method add_nodes()

Create an entry for node in the tracker. Assumes that node is not in the tracker yet, and does not check if this is the case.

Usage

Tracker$add_nodes(nodes, preference = 0)

Arguments

nodes

The name(s) of node(s) in the graph as a character vector.

preference

TODO: recall what on earth this is.


Method add_failed()

Add node to the list of nodes we failed to visit. Assumes that node is not in the failed list yet, and does not check if this is the case.

Usage

Tracker$add_failed(nodes)

Arguments

nodes

The name of the node in the graph as a length 1 character vector.


Method update_p()

Update the estimate of the personalized pagerank for a given node

Usage

Tracker$update_p(node)

Arguments

node

Character name of a node in the graph.


Method update_r_neighbor()

Update the residual of a good node in the neighborhood of the current node, adding it to the tracker if necessary

Usage

Tracker$update_r_neighbor(u, v)

Arguments

u

Character name of the node we are currently visiting.

v

Names of neighbors of u as a character vector. Can contain multiple elements. Can also contain zero elements.


Method update_r_self()

Update the residual of current node

Usage

Tracker$update_r_self(node)

Arguments

node

Character name of the node we are currently visiting.


Method regularize()

Compute the degree-adjusted and regularized variants of personalized PageRank as in Algorithm 4, based on the outputs of Algorithm 3.

Usage

Tracker$regularize()

Arguments

node

Character name of the node we are currently visiting.


Method calculate_ppr()

Main driver function to perform the computations outlined in Algorithm 3.

Usage

Tracker$calculate_ppr()

Arguments

node

Character name of the node we are currently visiting.


Method clone()

The objects of this class are cloneable with this method.

Usage

Tracker$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.