Skip to content

Commit

Permalink
Removes the networkx_algorithm decorator to all SCC functions to di…
Browse files Browse the repository at this point in the history
…sable dispatching to them (#4120)

The current cugraph `strongly_connected_components` is a legacy implementation with known issues, and in most cases should not be used until the cugraph team can provide an update.  

This PR removes the `networkx_algorithm` decorator from all SCC functions to disable dispatching.  Users can still run the SCC functions here by accessing them directly from `nx_cugraph`:

```python
>>> import nx_cugraph as nxcg
>>> nxcg.strongly_connected_components(...)
```

Tested by running the `nx_cugraph` tests (`pytest nx_cugraph/tests`) and the NetworkX tests (`run_nx_tests.sh`)

_Note: using the "non-breaking" label since this API was only present in nightlies and never released._

Authors:
  - Rick Ratzel (https://github.com/rlratzel)
  - Brad Rees (https://github.com/BradReesWork)

Approvers:
  - Erik Welch (https://github.com/eriknw)

URL: #4120
  • Loading branch information
rlratzel authored Feb 2, 2024
1 parent 3d52f17 commit acb3add
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
9 changes: 5 additions & 4 deletions python/nx-cugraph/_nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
# limitations under the License.
"""Tell NetworkX about the cugraph backend. This file can update itself:
$ make plugin-info # Recommended method for development
$ make plugin-info
or
$ make all # Recommended - runs 'plugin-info' followed by 'lint'
or
Expand Down Expand Up @@ -78,7 +82,6 @@
"is_connected",
"is_forest",
"is_isolate",
"is_strongly_connected",
"is_tree",
"is_weakly_connected",
"isolates",
Expand All @@ -96,7 +99,6 @@
"number_connected_components",
"number_of_isolates",
"number_of_selfloops",
"number_strongly_connected_components",
"number_weakly_connected_components",
"octahedral_graph",
"out_degree_centrality",
Expand All @@ -111,7 +113,6 @@
"single_source_shortest_path_length",
"single_target_shortest_path_length",
"star_graph",
"strongly_connected_components",
"tadpole_graph",
"tetrahedral_graph",
"transitivity",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
import pylibcugraph as plc

from nx_cugraph.convert import _to_directed_graph
from nx_cugraph.utils import (
_groupby,
index_dtype,
networkx_algorithm,
not_implemented_for,
)
from nx_cugraph.utils import _groupby, index_dtype, not_implemented_for

__all__ = [
"number_strongly_connected_components",
Expand Down Expand Up @@ -50,8 +45,19 @@ def _strongly_connected_components(G):
return labels


# The networkx_algorithm decorator is (temporarily) removed to disable
# dispatching for this function. The current cugraph
# strongly_connected_components is a legacy implementation with known issues,
# and in most cases should not be used until the cugraph team can provide an
# update.
#
# Users can still call this via the nx_cugraph module directly:
# >>> import nx_cugraph as nxcg
# >>> nxcg.strongly_connected_components(...)


@not_implemented_for("undirected")
@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
def strongly_connected_components(G):
G = _to_directed_graph(G)
if G.src_indices.size == 0:
Expand All @@ -62,7 +68,7 @@ def strongly_connected_components(G):


@not_implemented_for("undirected")
@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
def number_strongly_connected_components(G):
G = _to_directed_graph(G)
if G.src_indices.size == 0:
Expand All @@ -72,7 +78,7 @@ def number_strongly_connected_components(G):


@not_implemented_for("undirected")
@networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
# @networkx_algorithm(version_added="24.02", _plc="strongly_connected_components")
def is_strongly_connected(G):
G = _to_directed_graph(G)
if len(G) == 0:
Expand Down
12 changes: 8 additions & 4 deletions python/nx-cugraph/nx_cugraph/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ def key(testpath):
no_string_dtype = "string edge values not currently supported"

xfail = {
key(
"test_strongly_connected.py:"
"TestStronglyConnected.test_condensation_mapping_and_members"
): "Strongly connected groups in different iteration order",
# This is removed while strongly_connected_components() is not
# dispatchable. See algorithms/components/strongly_connected.py for
# details.
#
# key(
# "test_strongly_connected.py:"
# "TestStronglyConnected.test_condensation_mapping_and_members"
# ): "Strongly connected groups in different iteration order",
}

from packaging.version import parse
Expand Down

0 comments on commit acb3add

Please sign in to comment.