com.pawjaw.graph.fppr
Class Graph

java.lang.Object
  extended by com.pawjaw.graph.fppr.Graph

public final class Graph
extends java.lang.Object

This is a structure for representing a graph capable of performing Fully Personalized PageRank efficiently through random walk sampling.

This structure can be used as follows:

  1. A Graph instance is instantiated with the number of Vertex elements in the graph.
  2. Following this, all outgoing edges are specified with Vertex.addOutgoingEdge(Vertex, float).
  3. After the edges are set, random walks are simulated on the graph using the walk(int) method.
  4. Finally, for Vertex elements for which a Personalized PageRank is desired, the rank(int,int,List) is used.


Nested Class Summary
protected static class Graph.Step
           
 
Field Summary
static float RESET_PROBABILITY
          The probability of ending a random walk segment and either resetting to a source vertex or jumping to another random vertex.
 
Constructor Summary
Graph(int vertex_count)
           
 
Method Summary
 java.util.List<java.lang.Integer> rank(int start_vertex_id, int walk_length, java.util.List<java.lang.Integer> result)
          Obtain a descending ranking of nearest neighbors according to a Personalized PageRank of this Graph.
 Vertex vertex(int vertex_id)
           
 int vertices()
           
 void walk(int walks_per_vertex)
          Simulate random walks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESET_PROBABILITY

public static final float RESET_PROBABILITY
The probability of ending a random walk segment and either resetting to a source vertex or jumping to another random vertex.

See Also:
Constant Field Values
Constructor Detail

Graph

public Graph(int vertex_count)
Parameters:
vertex_count - number of Vertex elements in the graph
Method Detail

vertex

public Vertex vertex(int vertex_id)
Parameters:
vertex_id - the id of the vertex to retrieve. Starting at zero and going to the number of Vertex elements specified in the constructor (exclusive).
Returns:
the Vertex element corresponding to the specified vertex id.

vertices

public int vertices()
Returns:
the number of Vertex elements specified in the constructor.

walk

public void walk(int walks_per_vertex)
Simulate random walks.

Parameters:
walks_per_vertex - the number of random walks per Vertex to take. This number should be proportional to the logarithm of the number of vertices. For graphs that will fit in main memory, this number will probably not need exceed 10 or 15. A walk is a successive number of weighted random transitions following outgoing edges until a reset is encountered.
See Also:
RESET_PROBABILITY

rank

public java.util.List<java.lang.Integer> rank(int start_vertex_id,
                                              int walk_length,
                                              java.util.List<java.lang.Integer> result)
Obtain a descending ranking of nearest neighbors according to a Personalized PageRank of this Graph.

Parameters:
start_vertex_id - the id of the source Vertex for which to perform the Personalized PageRank and obtain neighbors. This number goes from zero to the number of vertices specified in the constructor (exclusive)
walk_length - the total number of walk steps taken. Resets to the Vertex specified by the start_vertex_id are also counted as a walk step. A reasonable number for this is on the order of 10,000.
result - a user-specified destination for storing the ranked Vertex ids such that the nearest neighbor will be stored first.
Returns:
the user-specified destination for storing the ranked Vertex ids (returned for convenience).