public class PageRank
extends java.lang.Object
implements java.io.Closeable
Implements the PageRank algorithm
Constructor and Description |
---|
PageRank(Session session)
Builds the PageRank.
|
Modifier and Type | Method and Description |
---|---|
void |
addAllEdgeTypes(EdgesDirection dir)
Allows for traversing all edge types of the graph.
|
void |
addAllNodeTypes()
Allows for traversing all node types of the graph.
|
void |
addEdgeType(int type,
EdgesDirection dir)
Allows for traversing edges of the given type.
|
void |
addNodeType(int type)
Allows for traversing nodes of the given type.
|
void |
close()
Closes the PageRank instance.
|
boolean |
isClosed()
Gets if PageRank instance has been closed or not.
|
void |
run()
Runs the algorithm.
|
void |
setDamping(double damping)
Sets the damping value for the PageRank.
|
void |
setDefaultWeight(double weight)
Sets the default weight for those cases when a given edge does not have a weight attribute set.
|
void |
setEdgeWeightAttributeType(int attr)
Sets the attribute to use as edge weight.
|
void |
setInitialPageRankValue(double startValue)
Sets the initial PageRank value.
|
void |
setNumIterations(int numIterations)
Sets the number of iterations to run the PageRank for.
|
void |
setOutputAttributeType(int attr)
Sets the output attribute type.
|
void |
setStartingNode(long startNode)
Sets the starting node of the page rank to compute the Personalized PageRank variant.
|
void |
setTolerance(double tolerance)
Sets the tolerance threashold to continue computing the PageRank after each iteration.
|
public PageRank(Session session)
session
- [in] The session to usepublic void setDamping(double damping)
damping
- [in] The damping value. Default: 0.85public void setDefaultWeight(double weight)
Default: 0.0
weight
- [in] The default weightpublic void run() throws java.lang.RuntimeException
sparksee::gdb::Error
java.lang.RuntimeException
- nullpublic void addAllEdgeTypes(EdgesDirection dir)
The direction is interpreted as in which direction an edge can be followed from a node to influence other nodes.
dir
- [in] Edge direction.public void setOutputAttributeType(int attr) throws java.lang.RuntimeException
If the PageRank will run on more than one node type, then the output attribute must be of type GLOBAL_TYPE or NODES_TYPE. Otherwise, it must be a valid attribute for the used node type.
attr
- [in] The attribute to store the result. Default: InvalidAttributejava.lang.RuntimeException
- nullpublic void setStartingNode(long startNode) throws java.lang.RuntimeException
sparksee::gdb::Error
startNode
- nulljava.lang.RuntimeException
- nullpublic void setInitialPageRankValue(double startValue)
If a starting node is set, this initial value is only set for the starting node and the rest of nodes are set to 0.0
startValue
- [in] The initial value to set. Default: 0.0public void setEdgeWeightAttributeType(int attr) throws java.lang.RuntimeException
If the multiple edge are set for traversal, this attribute must be of type GLOBAL_TYPE or EDGES_TYPE. Additionally, the attribute must be of type Double. Finally, negative weights are treated as non existing, so the default weight applies.
sparksee::gdb::Error
attr
- [in] The attribute type to use as a weight. Default: InvalidAttributejava.lang.RuntimeException
- nullpublic void addEdgeType(int type, EdgesDirection dir) throws java.lang.RuntimeException
If the edge type was already added, the existing direction is overwritten The direction is interpreted as in which direction an edge can be followed from a node to influence other nodes.
type
- [in] Edge type.dir
- [in] Edge direction.java.lang.RuntimeException
- nullpublic void setNumIterations(int numIterations)
numIterations
- [in] The number of interations to set. Default: 20public void setTolerance(double tolerance)
If all the changes to any PPR value after an iteration are below that tolerance threshold, the algorithm finishes.
tolerance
- [in] The tolerance to use normalized between 0 and 1. Default: 0.000001public boolean isClosed()
close()
public void addNodeType(int type) throws java.lang.RuntimeException
type
- nulljava.lang.RuntimeException
- nullpublic void close()
It must be called to ensure the integrity of all data.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void addAllNodeTypes()