-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nx-cugraph: add weakly connected components (PLC needs updated!)
- Loading branch information
Showing
4 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
python/nx-cugraph/nx_cugraph/algorithms/components/weakly_connected.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from nx_cugraph.convert import _to_directed_graph | ||
from nx_cugraph.utils import networkx_algorithm, not_implemented_for | ||
|
||
from .connected import ( | ||
_connected_components, | ||
_is_connected, | ||
_number_connected_components, | ||
) | ||
|
||
__all__ = [ | ||
"number_weakly_connected_components", | ||
"weakly_connected_components", | ||
"is_weakly_connected", | ||
] | ||
|
||
|
||
@not_implemented_for("undirected") | ||
@networkx_algorithm | ||
def weakly_connected_components(G): | ||
G = _to_directed_graph(G) | ||
return _connected_components(G) | ||
|
||
|
||
@not_implemented_for("undirected") | ||
@networkx_algorithm | ||
def number_weakly_connected_components(G): | ||
G = _to_directed_graph(G) | ||
return _number_connected_components(G) | ||
|
||
|
||
@not_implemented_for("undirected") | ||
@networkx_algorithm | ||
def is_weakly_connected(G): | ||
G = _to_directed_graph(G) | ||
return _is_connected(G) |