public class Pregel extends java.lang.Object implements Logging
Unlike the original Pregel API, the GraphX Pregel API factors the sendMessage computation over edges, enables the message sending computation to read both vertex attributes, and constrains messages to the graph structure. These changes allow for substantially more efficient distributed execution while also exposing greater flexibility for graph-based computation.
Constructor and Description |
---|
Pregel() |
Modifier and Type | Method and Description |
---|---|
static <VD,ED,A> Graph<VD,ED> |
apply(Graph<VD,ED> graph,
A initialMsg,
int maxIterations,
EdgeDirection activeDirection,
scala.Function3<java.lang.Object,VD,A,VD> vprog,
scala.Function1<EdgeTriplet<VD,ED>,scala.collection.Iterator<scala.Tuple2<java.lang.Object,A>>> sendMsg,
scala.Function2<A,A,A> mergeMsg,
scala.reflect.ClassTag<VD> evidence$1,
scala.reflect.ClassTag<ED> evidence$2,
scala.reflect.ClassTag<A> evidence$3)
Execute a Pregel-like iterative vertex-parallel abstraction.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeIfNecessary, initializeLogging, isTraceEnabled, log_, log, logDebug, logDebug, logError, logError, logInfo, logInfo, logName, logTrace, logTrace, logWarning, logWarning
public static <VD,ED,A> Graph<VD,ED> apply(Graph<VD,ED> graph, A initialMsg, int maxIterations, EdgeDirection activeDirection, scala.Function3<java.lang.Object,VD,A,VD> vprog, scala.Function1<EdgeTriplet<VD,ED>,scala.collection.Iterator<scala.Tuple2<java.lang.Object,A>>> sendMsg, scala.Function2<A,A,A> mergeMsg, scala.reflect.ClassTag<VD> evidence$1, scala.reflect.ClassTag<ED> evidence$2, scala.reflect.ClassTag<A> evidence$3)
vprog
is executed in parallel on
each vertex receiving any inbound messages and computing a new
value for the vertex. The sendMsg
function is then invoked on
all out-edges and is used to compute an optional message to the
destination vertex. The mergeMsg
function is a commutative
associative function used to combine messages destined to the
same vertex.
On the first iteration all vertices receive the initialMsg
and
on subsequent iterations if a vertex does not receive a message
then the vertex-program is not invoked.
This function iterates until there are no remaining messages, or
for maxIterations
iterations.
graph
- the input graph.
initialMsg
- the message each vertex will receive at the first
iteration
maxIterations
- the maximum number of iterations to run for
activeDirection
- the direction of edges incident to a vertex that received a message in
the previous round on which to run sendMsg
. For example, if this is EdgeDirection.Out
, only
out-edges of vertices that received a message in the previous round will run. The default is
EdgeDirection.Either
, which will run sendMsg
on edges where either side received a message
in the previous round. If this is EdgeDirection.Both
, sendMsg
will only run on edges where
*both* vertices received a message.
vprog
- the user-defined vertex program which runs on each
vertex and receives the inbound message and computes a new vertex
value. On the first iteration the vertex program is invoked on
all vertices and is passed the default message. On subsequent
iterations the vertex program is only invoked on those vertices
that receive messages.
sendMsg
- a user supplied function that is applied to out
edges of vertices that received messages in the current
iteration
mergeMsg
- a user supplied function that takes two incoming
messages of type A and merges them into a single message of type
A. ''This function must be commutative and associative and
ideally the size of A should not increase.''
evidence$1
- (undocumented)evidence$2
- (undocumented)evidence$3
- (undocumented)