turicreate.triangle_counting.create¶

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.
Parameters:  graph : SGraph
The graph on which to compute triangle counts.
 verbose : bool, optional
If True, print progress updates.
Returns:  out : TriangleCountingModel
See also
References
 T. Schank. (2007) Algorithmic Aspects of TriangleBased Network Analysis.
Examples
If given an
SGraph
g
, we can create aTriangleCountingModel
as follows:>>> g = >>> turicreate.load_sgraph('http://snap.stanford.edu/data/emailEnron.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()
.