turicreate.connected_components.create¶
-
turicreate.connected_components.
create
(graph, verbose=True)¶ Compute the number of weakly connected components in the graph. Return a model object with total number of weakly connected components as well as the component ID for each vertex in the graph.
Parameters: - graph : SGraph
The graph on which to compute the triangle counts.
- verbose : bool, optional
If True, print progress updates.
Returns: - out : ConnectedComponentsModel
See also
References
Examples
If given an
SGraph
g
, we can create aConnectedComponentsModel
as follows:>>> g = turicreate.load_sgraph('http://snap.stanford.edu/data/email-Enron.txt.gz', format='snap') >>> cc = turicreate.connected_components.create(g) >>> cc.summary()
We can obtain the
component id
corresponding to each vertex in the graphg
as follows:>>> cc_ids = cc['component_id'] # SFrame
We can obtain a graph with additional information about the
component id
corresponding to each vertex as follows:>>> cc_graph = cc['graph'] # SGraph
We can add the new component_id field to the original graph g using:
>>> g.vertices['component_id'] = cc['graph'].vertices['component_id']
Note that the task above does not require a join because the vertex ordering is preserved through
create()
.