deepgraph.deepgraph.DeepGraph.append_cp¶
-
DeepGraph.
append_cp
(directed=False, connection='weak', col_name='cp', label_by_size=True, consolidate_singles=False)[source]¶ Append a component membership column to
v
.Append a column to
v
indicating the component membership of each node. Requires scipy.Parameters: - directed (bool, optional (default=False)) – If True , then operate on a directed graph: only move from point i to point j along paths csgraph[i, j]. If False, then find the shortest path on an undirected graph: the algorithm can progress from point i to j along csgraph[i, j] or csgraph[j, i].
- connection (str, optional (default='weak')) – One of {‘weak’,’strong’}. For directed graphs, the type of
connection to use. Nodes i and j are strongly connected if a path
exists both from i to j and from j to i. Nodes i and j are weakly
connected if only one of these paths exists. Only has an effect if
directed
is True - col_name (str, optional (default='cp')) – The name of the appended column of component labels.
- label_by_size (bool, optional (default=True)) – Whether to rename component membership labels to reflect component
sizes. If True, the smallest component corresponds to the largest
label, and the largest component corresponds to the label 0 (or 1
if
consolidate_singles
is True). If False, pass on labels given by scipy’s connected_components method directly (faster and uses less memory). - consolidate_singles (bool, optional (default=False)) – If True, all singular components (components comprised of one node
only) are consolidated under the label 0. Also, all other labels
are renamed to reflect component sizes, see
label_by_size
.
Returns: v – appends an extra column to
v
indicating component membership.Return type: pd.DataFrame