Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11290#discussion_r53566028
  
    --- Diff: 
graphx/src/main/scala/org/apache/spark/graphx/lib/TriangleCount.scala ---
    @@ -80,15 +103,18 @@ object TriangleCount {
           ctx.sendToSrc(counter)
           ctx.sendToDst(counter)
         }
    +
         // compute the intersection along edges
         val counters: VertexRDD[Int] = setGraph.aggregateMessages(edgeFunc, _ 
+ _)
         // Merge counters with the graph and divide by two since each triangle 
is counted twice
    -    g.outerJoinVertices(counters) {
    -      (vid, _, optCounter: Option[Int]) =>
    -        val dblCount = optCounter.getOrElse(0)
    -        // double count should be even (divisible by two)
    -        assert((dblCount & 1) == 0)
    -        dblCount / 2
    +    graph.outerJoinVertices(counters) { (vid, _, optCounter: Option[Int]) 
=>
    +      val dblCount = optCounter.getOrElse(0)
    +      // This algorithm double counts each triangle so the final count 
should be even
    +      val isEven = (dblCount & 1) == 0
    +      if (!isEven) {
    +        throw new Exception("Triangle count resulted in an invalid number 
of triangles.")
    --- End diff --
    
    I would just `require(...)` this condition. `(dblCount % 2) == 0` would be 
a little more canonical


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to