For more details see:
T. Roughgarden, Reading in Algorithms Counting Triangles, Stanford University (2014)