Is there a primitive function for counting triangles in graph-tool?

The closest one is global_clustering(), which returns:

3 x number of triangles / number of connected triples

the denominator is easy to compute from the degrees alone (the number of
triples a node with degree k participates is simply k(k-1)/2). Hence,
you can get the number of triangles with:

Thank you for your detailed reply, it cleared things up a lot! I would also like to thank you for your incredible work on graph-tool, its a great package!

Below is the code i now use to count the triangles -

# number of triangles
gc = global_clustering(tempG)
d = tempG.degree_property_map("total")
num_triangles = gc[0] * (d.a * (d.a - 1) / 2).sum() / 3

Many SNAP datasets contain parallel edges, but apparently many of their
statistics ignore those. Graph-tool (correctly) incorporates them in the
triangle counting. If you remove the parallel edges (e.g. with
remove_parallel_edges()), you get the same triangle count as reported in
SNAP.