Skip to content

Commit 1e6f5d2

Browse files
committed
code tidy up of run
1 parent d56ad1a commit 1e6f5d2

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,10 @@ object TriangleCount {
107107
// compute the intersection along edges
108108
val counters: VertexRDD[Int] = setGraph.aggregateMessages(edgeFunc, _ + _)
109109
// Merge counters with the graph and divide by two since each triangle is counted twice
110-
graph.outerJoinVertices(counters) { (vid, _, optCounter: Option[Int]) =>
110+
graph.outerJoinVertices(counters) { (_, _, optCounter: Option[Int]) =>
111111
val dblCount = optCounter.getOrElse(0)
112112
// This algorithm double counts each triangle so the final count should be even
113-
val isEven = (dblCount & 1) == 0
114-
if (!isEven) {
115-
throw new Exception("Triangle count resulted in an invalid number of triangles.")
116-
}
113+
require(dblCount % 2 == 0, "Triangle count resulted in an invalid number of triangles.")
117114
dblCount / 2
118115
}
119116
}

0 commit comments

Comments
 (0)