The input matrix should ensure that the following conditions hold:
- Undirected graph.
- No self edges.
- All edges are oriented (src ID is greater than dst ID for compressed sparse column (CSC) format or dst ID is greater than src ID for compressed sparse row (CSR) format).
- No duplicate edges.
The algorithm implementation is shown as the figure below:
As seen from the figure:
- Module row1CopyImpl and its previous module: first get the rows corresponding to the order of increasing columns, and then copy the rows according to the number of rows.
- Module row2Impl and its previous module: first, get the rows corresponding to the order of increasing columns, and then use the rows as columns to obtain their corresponding rows.
- Module mergeImpl and tcAccUnit: count the number of intersections of rows from module row1CopyImpl and module row2Impl in the order of the columns. The cumulative result is the number of triangles.