add a predicate to GraphLab to indicate active vertices at start

This commit is contained in:
Akihiro Matsukawa 2013-12-04 18:17:14 -08:00
parent 088995f917
commit 38c6f5f612

View file

@ -24,6 +24,8 @@ object GraphLab {
* @param scatterFunc Executed after the apply function the scatter function takes * @param scatterFunc Executed after the apply function the scatter function takes
* a triplet and signals whether the neighboring vertex program * a triplet and signals whether the neighboring vertex program
* must be recomputed. * must be recomputed.
* @param startVertices predicate to determine which vertices to start the computation on.
* these will be the active vertices in the first iteration.
* @param numIter The maximum number of iterations to run. * @param numIter The maximum number of iterations to run.
* @param gatherDirection The direction of edges to consider during the gather phase * @param gatherDirection The direction of edges to consider during the gather phase
* @param scatterDirection The direction of edges to consider during the scatter phase * @param scatterDirection The direction of edges to consider during the scatter phase
@ -40,12 +42,13 @@ object GraphLab {
(gatherFunc: (Vid, EdgeTriplet[VD, ED]) => A, (gatherFunc: (Vid, EdgeTriplet[VD, ED]) => A,
mergeFunc: (A, A) => A, mergeFunc: (A, A) => A,
applyFunc: (Vid, VD, Option[A]) => VD, applyFunc: (Vid, VD, Option[A]) => VD,
scatterFunc: (Vid, EdgeTriplet[VD, ED]) => Boolean): Graph[VD, ED] = { scatterFunc: (Vid, EdgeTriplet[VD, ED]) => Boolean,
startVertices: (Vid, VD) => Boolean = (vid: Vid, data: VD) => true): Graph[VD, ED] = {
// Add an active attribute to all vertices to track convergence. // Add an active attribute to all vertices to track convergence.
var activeGraph: Graph[(Boolean, VD), ED] = graph.mapVertices { var activeGraph: Graph[(Boolean, VD), ED] = graph.mapVertices {
case (id, data) => (true, data) case (id, data) => (startVertices(id, data), data)
}.cache() }.cache()
// The gather function wrapper strips the active attribute and // The gather function wrapper strips the active attribute and