NodeNameType
- The graph's node name type@PublicationReference(type=WebPage, title="Personalized PageRank code", author="dgleich", year=2016, url="https://gist.github.com/dgleich/6201856") public class PersonalizedPageRank<NodeNameType> extends java.lang.Object
Constructor and Description |
---|
PersonalizedPageRank(DirectedNodeEdgeGraph<NodeNameType> graph)
Initializes all of the internal data-structures for the input graph.
|
PersonalizedPageRank(DirectedNodeEdgeGraph<NodeNameType> graph,
double tolerance)
Initializes all of the internal data-structures for the input graph.
|
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.Integer> |
getCommunityForNode(NodeNameType node,
int numRunsPpr,
int numRunsCut)
Computes the best community for the input node id by personalized page
rank scores and conductance of cut.
|
java.util.Set<java.lang.Integer> |
getCommunityForNodeById(int nodeIdx,
int numRunsPpr,
int numRunsCut)
Computes the best community for the input node id by personalized page
rank scores and conductance of cut.
|
java.util.Set<java.lang.Integer> |
getCommunityForNodes(java.util.List<NodeNameType> nodes,
int numRunsPpr,
int numRunsCut)
Computes the best community for the input node id by personalized page
rank scores and conductance of cut.
|
java.util.Set<java.lang.Integer> |
getCommunityForNodesById(java.util.List<java.lang.Integer> nodeIdxs,
int numRunsPpr,
int numRunsCut)
Computes the best community for the input node id by personalized page
rank scores and conductance of cut.
|
DoubleArrayList |
getScoresForAllNodes(java.util.List<NodeNameType> nodes)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seeds
|
DoubleArrayList |
getScoresForAllNodes(java.util.List<NodeNameType> nodes,
boolean randomized)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seeds
|
DoubleArrayList |
getScoresForAllNodes(NodeNameType node)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph)
|
DoubleArrayList |
getScoresForAllNodes(NodeNameType node,
boolean randomized)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph)
|
DoubleArrayList |
getScoresForAllNodesById(int nodeIdx)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph)
|
DoubleArrayList |
getScoresForAllNodesById(int nodeIdx,
boolean randomized)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph)
|
DoubleArrayList |
getScoresForAllNodesByIdMultirun(int nodeIdx,
int numRuns)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed index.
|
DoubleArrayList |
getScoresForAllNodesByIdMultirun(java.util.List<java.lang.Integer> nodeIdxs,
int numRuns)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed index.
|
DoubleArrayList |
getScoresForAllNodesByIds(java.util.List<java.lang.Integer> nodeIdxs)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed indices
|
DoubleArrayList |
getScoresForAllNodesByIds(java.util.List<java.lang.Integer> nodeIdxs,
boolean randomized)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed indices
|
DoubleArrayList |
getScoresForAllNodesMultirun(java.util.List<NodeNameType> nodes,
int numRuns)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed index.
|
DoubleArrayList |
getScoresForAllNodesMultirun(NodeNameType node,
int numRuns)
Returns the vector of all scores for all nodes in the graph (order
determined by node order as stored in the graph) as specified for the
input seed.
|
void |
setRandomSet(long seed)
Initialize the random number generator with the input seed.
|
void |
setTolerance(double tolerance)
Set the tolerance to a new value.
|
public PersonalizedPageRank(DirectedNodeEdgeGraph<NodeNameType> graph)
graph
- The graph to compute personalized page rank forpublic PersonalizedPageRank(DirectedNodeEdgeGraph<NodeNameType> graph, double tolerance)
graph
- The graph to compute personalized page rank fortolerance
- The tolerance for further spreading PPR. Should be
fairly small 0.01 or smaller. The closer to 0, the further it will
spread. Setting to 0 could lead to never quite converging (so probably
don't do that).public void setTolerance(double tolerance)
tolerance
- The tolerance for further spreading PPR.public void setRandomSet(long seed)
seed
- The seed for the random number generatorpublic DoubleArrayList getScoresForAllNodes(NodeNameType node)
node
- The node to use as seedpublic DoubleArrayList getScoresForAllNodesById(int nodeIdx)
nodeIdx
- The node index to use as seedpublic DoubleArrayList getScoresForAllNodes(java.util.List<NodeNameType> nodes)
nodes
- The nodes to use as seedpublic DoubleArrayList getScoresForAllNodes(NodeNameType node, boolean randomized)
node
- The node to use as seedrandomized
- If true, the order nodes are treated within the
algorithm will be randomized so that you can get an average result across
multiple runs or just realize that any single run is not the completely
true answer.public DoubleArrayList getScoresForAllNodesById(int nodeIdx, boolean randomized)
nodeIdx
- The node index to use as seedrandomized
- If true, the order nodes are treated within the
algorithm will be randomized so that you can get an average result across
multiple runs or just realize that any single run is not the completely
true answer.public DoubleArrayList getScoresForAllNodes(java.util.List<NodeNameType> nodes, boolean randomized)
nodes
- The nodes to use as seedrandomized
- If true, the order nodes are treated within the
algorithm will be randomized so that you can get an average result across
multiple runs or just realize that any single run is not the completely
true answer.public DoubleArrayList getScoresForAllNodesByIds(java.util.List<java.lang.Integer> nodeIdxs)
nodeIdxs
- The node indices to use as seedpublic DoubleArrayList getScoresForAllNodesByIds(java.util.List<java.lang.Integer> nodeIdxs, boolean randomized)
nodeIdxs
- The node indices to use as seedrandomized
- If true, the order nodes are treated within the
algorithm will be randomized so that you can get an average result across
multiple runs or just realize that any single run is not the completely
true answer.public DoubleArrayList getScoresForAllNodesMultirun(NodeNameType node, int numRuns)
node
- The seed node to considernumRuns
- The number of runs to performpublic DoubleArrayList getScoresForAllNodesMultirun(java.util.List<NodeNameType> nodes, int numRuns)
nodes
- The seed nodesnumRuns
- The number of runs to performpublic DoubleArrayList getScoresForAllNodesByIdMultirun(int nodeIdx, int numRuns)
nodeIdx
- The seed node's idnumRuns
- The number of runs to performpublic DoubleArrayList getScoresForAllNodesByIdMultirun(java.util.List<java.lang.Integer> nodeIdxs, int numRuns)
nodeIdxs
- The seed nodes' idnumRuns
- The number of runs to performpublic java.util.Set<java.lang.Integer> getCommunityForNode(NodeNameType node, int numRunsPpr, int numRunsCut)
node
- The node whose community is desirednumRunsPpr
- The number of randomized runs to perform for the PPR
computationnumRunsCut
- The number of randomized runs to perform for community
determinationpublic java.util.Set<java.lang.Integer> getCommunityForNodeById(int nodeIdx, int numRunsPpr, int numRunsCut)
nodeIdx
- The node id whose community is desirednumRunsPpr
- The number of randomized runs to perform for the PPR
computationnumRunsCut
- The number of randomized runs to perform for community
determinationpublic java.util.Set<java.lang.Integer> getCommunityForNodes(java.util.List<NodeNameType> nodes, int numRunsPpr, int numRunsCut)
nodes
- The node(s) whose community is desirednumRunsPpr
- The number of randomized runs to perform for the PPR
computationnumRunsCut
- The number of randomized runs to perform for community
determinationpublic java.util.Set<java.lang.Integer> getCommunityForNodesById(java.util.List<java.lang.Integer> nodeIdxs, int numRunsPpr, int numRunsCut)
nodeIdxs
- The node id(s) whose community is desirednumRunsPpr
- The number of randomized runs to perform for the PPR
computationnumRunsCut
- The number of randomized runs to perform for community
determination