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
- T. Schank. (2007) Algorithmic Aspects of Triangle-Based Network Analysis.
>>> 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
gis 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