Compute the number of triangles passing through each vertex.
The algorithm is relatively straightforward and can be computed in three steps:
There are two implementations. The default TriangleCount.run implementation first removes
self cycles and canonicalizes the graph to ensure that the following conditions hold:
However, the canonicalization procedure is costly as it requires repartitioning the graph.
If the input data is already in "canonical form" with self cycles removed then the
TriangleCount.runPreCanonicalized should be used instead.
val canonicalGraph = graph.mapEdges(e => 1).removeSelfEdges().canonicalizeEdges()
val counts = TriangleCount.runPreCanonicalized(canonicalGraph).vertices