turicreate.triangle_counting.create(graph, verbose=True)

Compute the number of triangles each vertex belongs to, ignoring edge directions. A triangle is a complete subgraph with only three vertices. Return a model object with total number of triangles as well as the triangle counts for each vertex in the graph.

graph : SGraph

The graph on which to compute triangle counts.

verbose : bool, optional

If True, print progress updates.

out : TriangleCountingModel



If given an SGraph g, we can create a TriangleCountingModel as follows:

>>> g =
>>> turicreate.load_sgraph('http://snap.stanford.edu/data/email-Enron.txt.gz',
        >>> format='snap') tc = turicreate.triangle_counting.create(g)

We can obtain the number of triangles that each vertex in the graph g is present in:

>>> tc_out = tc['triangle_count']  # SFrame

We can add the new “triangle_count” field to the original graph g using:

>>> g.vertices['triangle_count'] = tc['graph'].vertices['triangle_count']

Note that the task above does not require a join because the vertex ordering is preserved through create().