Skip to content

Commit

Permalink
tc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeamer committed Aug 18, 2015
1 parent 4b58f36 commit 5428a4f
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,37 @@
#include "pvector.h"


using namespace std;
/*
GAP Benchmark Suite
Kernel: Triangle Counting (TC)
Author: Scott Beamer
Will count the number of triangles (cliques of size 3)
Requires input graph:
- to be undirected
- no duplicate edges (or else will be counted as multiple triangles)
- neighborhoods are sorted by vertex identifiers
Other than symmetrizing, the rest of the requirements are done by SquishCSR
during graph building.
This implementation reduces the search space by counting each triangle only
once. A naive implementation will count the same triangle six times because
each of the three vertices (u, v, w) will count it in both ways. To count
a triangle only once, this implementation only counts a triangle if u > v > w.
Once the remaining unexamined neighbors identifiers get too big, it can break
out of the loop, but this requires that the neighbors to be sorted.
Another optimization this implementation has is to relabel the vertices by
degree. This is beneficial if the average degree is high enough and if the
degree distribution is sufficiently non-uniform. To decide whether or not
to relabel the graph, we use the heuristic in WorthRelabelling.
*/


using namespace std;

// assumes neighborhoods are sorted, no self loops, no duplicate edges
// counts triangles only once by ordering u>v>w
size_t OrderedCount(const Graph &g) {
size_t total = 0;
#pragma omp parallel for reduction(+ : total) schedule(dynamic)
Expand Down

0 comments on commit 5428a4f

Please sign in to comment.