components
Algorithms to calculate connected components.
connected_components
¶
Compute the connected components of a graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
pathpyG.core.graph.Graph
|
The input graph. |
required |
connection
|
str
|
Type of connection to consider. Options are "weak" or "strong". Defaults to "weak". |
'weak'
|
Returns:
| Type | Description |
|---|---|
typing.Tuple[int, numpy.ndarray]
|
Tuple[int, np.ndarray]: A tuple containing the number of connected components and an array with component labels for each node. |
Source code in src/pathpyG/algorithms/components.py
largest_connected_component
¶
Extract the largest connected component from a graph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
graph
|
pathpyG.core.graph.Graph
|
The input graph. |
required |
connection
|
str
|
Type of connection to consider. Options are "weak" or "strong". Defaults to "weak". |
'weak'
|
Returns:
| Name | Type | Description |
|---|---|---|
Graph |
pathpyG.core.graph.Graph
|
A new graph instance containing only the largest connected component. |