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.
- graph : SGraph
The graph on which to compute the triangle counts.
- verbose : bool, optional
If True, print progress updates.
- out : ConnectedComponentsModel
>>> 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 idcorresponding to each vertex in the graph
>>> cc_ids = cc['component_id'] # SFrame
We can obtain a graph with additional information about the
component idcorresponding 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