diff options
author | Reynold Xin <rxin@cs.berkeley.edu> | 2013-04-05 14:47:39 +0800 |
---|---|---|
committer | Reynold Xin <rxin@cs.berkeley.edu> | 2013-04-05 14:47:39 +0800 |
commit | e5dd61e720520dabea6f0b4d84eb135175c17f6a (patch) | |
tree | 659c38adb0c5cd86a895b481cb3348dc2a1f31b2 /graph | |
parent | c973e564b92d18d756d9b31e5ef9ffb01d090e1b (diff) | |
download | spark-e5dd61e720520dabea6f0b4d84eb135175c17f6a.tar.gz spark-e5dd61e720520dabea6f0b4d84eb135175c17f6a.tar.bz2 spark-e5dd61e720520dabea6f0b4d84eb135175c17f6a.zip |
Rename rawGraph to graph.
Diffstat (limited to 'graph')
-rw-r--r-- | graph/src/main/scala/spark/graph/GraphLab.scala | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/graph/src/main/scala/spark/graph/GraphLab.scala b/graph/src/main/scala/spark/graph/GraphLab.scala index 2a906d73d5..b0efdadce9 100644 --- a/graph/src/main/scala/spark/graph/GraphLab.scala +++ b/graph/src/main/scala/spark/graph/GraphLab.scala @@ -55,7 +55,7 @@ object GraphLab { g } - def iterateGAS[VD: ClassManifest, ED: ClassManifest, A: ClassManifest](rawGraph: Graph[VD, ED])( + def iterateGAS[VD: ClassManifest, ED: ClassManifest, A: ClassManifest](graph: Graph[VD, ED])( gatherFunc: (Vid, EdgeWithVertices[VD, ED]) => A, mergeFunc: (A, A) => A, applyFunc: (Vertex[VD], Option[A]) => VD, @@ -64,7 +64,7 @@ object GraphLab { gatherDirection: EdgeDirection = EdgeDirection.In, scatterDirection: EdgeDirection = EdgeDirection.Out) : Graph[VD, ED] = { - var graph = rawGraph.mapVertices{ case Vertex(id,data) => Vertex(id, (true, data)) }.cache() + var g = graph.mapVertices{ case Vertex(id,data) => Vertex(id, (true, data)) }.cache() def gather(vid: Vid, e: EdgeWithVertices[(Boolean, VD), ED]) = { if(e.vertex(vid).data._1) { @@ -98,24 +98,25 @@ object GraphLab { (accum.getOrElse(false), v.data._2) var i = 0 - var numActive = graph.numVertices + var numActive = g.numVertices while (i < numIter && numActive > 0) { val accUpdates: RDD[(Vid, A)] = - graph.flatMapReduceNeighborhood(gather, mergeFunc, gatherDirection) + g.flatMapReduceNeighborhood(gather, mergeFunc, gatherDirection) - graph = graph.updateVertices(accUpdates, apply).cache() + g = g.updateVertices(accUpdates, apply).cache() // Scatter is basically a gather in the opposite direction so we reverse the edge direction val activeVertices: RDD[(Vid, Boolean)] = - graph.flatMapReduceNeighborhood(scatter, _ || _, scatterDirection.reverse) + g.flatMapReduceNeighborhood(scatter, _ || _, scatterDirection.reverse) - graph = graph.updateVertices(activeVertices, applyActive).cache() + g = g.updateVertices(activeVertices, applyActive).cache() - numActive = graph.vertices.map(v => if (v.data._1) 1 else 0).reduce( _ + _ ) + numActive = g.vertices.map(v => if (v.data._1) 1 else 0).reduce( _ + _ ) println("Number active vertices: " + numActive) i += 1 } - graph.mapVertices(v => Vertex(v.id, v.data._2)) + + g.mapVertices(v => Vertex(v.id, v.data._2)) } } |