Class ComputeContext<CONFIG extends PregelConfig>
- java.lang.Object
-
- org.neo4j.graphalgo.beta.pregel.context.PregelContext<CONFIG>
-
- org.neo4j.graphalgo.beta.pregel.context.NodeCentricContext<CONFIG>
-
- org.neo4j.graphalgo.beta.pregel.context.ComputeContext<CONFIG>
-
public final class ComputeContext<CONFIG extends PregelConfig> extends NodeCentricContext<CONFIG>
A context that is used during the computation. It allows an implementation to send messages to other nodes and change the state of the currently processed node.
-
-
Field Summary
-
Fields inherited from class org.neo4j.graphalgo.beta.pregel.context.NodeCentricContext
computeStep
-
Fields inherited from class org.neo4j.graphalgo.beta.pregel.context.PregelContext
config
-
-
Constructor Summary
Constructors Constructor Description ComputeContext(ComputeStep<CONFIG,?> computeStep, CONFIG config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double[]
doubleArrayNodeValue(java.lang.String key)
Returns the node value for the given node schema key.double
doubleNodeValue(java.lang.String key)
Returns the node value for the given node schema key.boolean
isInitialSuperstep()
Indicates if the current superstep is the first superstep.long[]
longArrayNodeValue(java.lang.String key)
Returns the node value for the given node schema key.long[]
longArrayNodeValue(java.lang.String key, long id)
Returns the node value for the given node-id and node schema key.long
longNodeValue(java.lang.String key)
Returns the node value for the given node schema key.void
sendTo(long targetNodeId, double message)
Sends the given message to the target node.void
sendToNeighbors(double message)
Sends the given message to all neighbors of the node.int
superstep()
Returns the current superstep (0-based).void
voteToHalt()
Notify the execution framework that this node intends to stop the computation.-
Methods inherited from class org.neo4j.graphalgo.beta.pregel.context.NodeCentricContext
degree, forEachDistinctNeighbor, forEachDistinctNeighbor, forEachNeighbor, forEachNeighbor, isMultiGraph, nodeCount, nodeId, relationshipCount, setNodeId, setNodeValue, setNodeValue, setNodeValue, setNodeValue
-
Methods inherited from class org.neo4j.graphalgo.beta.pregel.context.PregelContext
config
-
-
-
-
Constructor Detail
-
ComputeContext
public ComputeContext(ComputeStep<CONFIG,?> computeStep, CONFIG config)
-
-
Method Detail
-
doubleNodeValue
public double doubleNodeValue(java.lang.String key)
Returns the node value for the given node schema key.- Throws:
java.lang.IllegalArgumentException
- if the key does not exist or the value is not a double
-
longNodeValue
public long longNodeValue(java.lang.String key)
Returns the node value for the given node schema key.- Throws:
java.lang.IllegalArgumentException
- if the key does not exist or the value is not a long
-
longArrayNodeValue
public long[] longArrayNodeValue(java.lang.String key)
Returns the node value for the given node schema key.- Throws:
java.lang.IllegalArgumentException
- if the key does not exist or the value is not a long array
-
longArrayNodeValue
public long[] longArrayNodeValue(java.lang.String key, long id)
Returns the node value for the given node-id and node schema key.- Throws:
java.lang.IllegalArgumentException
- if the key does not exist or the value is not a long array
-
doubleArrayNodeValue
public double[] doubleArrayNodeValue(java.lang.String key)
Returns the node value for the given node schema key.- Throws:
java.lang.IllegalArgumentException
- if the key does not exist or the value is not a double array
-
voteToHalt
public void voteToHalt()
Notify the execution framework that this node intends to stop the computation. If the node voted to halt and has not received new messages in the next superstep, the compute method will not be called for that node. If a node receives messages, the vote to halt flag will be ignored.
-
isInitialSuperstep
public boolean isInitialSuperstep()
Indicates if the current superstep is the first superstep.
-
superstep
public int superstep()
Returns the current superstep (0-based).
-
sendToNeighbors
public void sendToNeighbors(double message)
Sends the given message to all neighbors of the node.
-
sendTo
public void sendTo(long targetNodeId, double message)
Sends the given message to the target node. The target node can be any existing node id in the graph.- Throws:
java.lang.ArrayIndexOutOfBoundsException
- if the node is in the not in id space
-
-