From 1f589ed114521c5c57d880f09a06633008aba4e0 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 6 Sep 2023 13:04:23 -0500 Subject: [PATCH 01/51] Rename `cugraph-nx` to `nx-cugraph` (#3840) We decided to rename `cugraph-nx` to `nx-cugraph` to follow (and help establish) conventions for names of networkx backends. See: https://github.com/networkx/networkx/discussions/6883 This PR was created from the following commands: ```sh mv notebooks/ ../notebooks-bak find * -type f -print0 | xargs -0 sed -i 's/cugraph_nx/nx_cugraph/g' find * -type f -print0 | xargs -0 sed -i 's/cugraph-nx/nx-cugraph/g' git mv ./conda/recipes/cugraph-nx ./conda/recipes/nx-cugraph git mv ./python/cugraph-nx ./python/nx-cugraph git mv ./python/nx-cugraph/cugraph_nx ./python/nx-cugraph/nx_cugraph mv ../notebooks-bak/ notebooks ``` (a more reliable bash script would ensure the destination of `git mv` does not exist yet, b/c if the destination is a directory, it will happily--and incorrectly--move the target _into_ the directory) ```sh # Make sure everything got renamed correctly git grep -i 'cugraph.nx' find . -iname '*cugraph*nx*' -print ``` Should we remove `cugraph-nx` nightlies once this is merged? Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/cugraph/pull/3840 --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..e7cd26218 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# nx-cugraph + +## Description +[RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/reference/classes/index.html#backends) +with minimal dependencies (`networkx`, `cupy`, and `pylibcugraph`) to run graph algorithms on the GPU. + +### Contribute + +Follow instructions for [contributing to cugraph](https://github.com/rapidsai/cugraph/blob/branch-23.10/readme_pages/CONTRIBUTING.md) +and [building from source](https://docs.rapids.ai/api/cugraph/stable/installation/source_build/), then build nx-cugraph in develop (i.e., editable) mode: +``` +$ ./build.sh nx-cugraph --pydevelop +``` + +### Run tests + +Run nx-cugraph tests from `cugraph/python/nx-cugraph` directory: +``` +$ pytest +``` +Run nx-cugraph benchmarks: +``` +$ pytest --bench +``` +Run networkx tests (requires networkx version 3.2): +``` +$ ./run_nx_tests.sh +``` +Additional arguments may be passed to pytest such as: +``` +$ ./run_nx_tests.sh -x --sw -k betweenness +``` From 429797d9c5c786de4d1cfad8db9e85f30341b529 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Fri, 22 Sep 2023 10:58:08 -0400 Subject: [PATCH 02/51] v23.12 Updates [skip ci] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e7cd26218..ab267e5a7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ with minimal dependencies (`networkx`, `cupy`, and `pylibcugraph`) to run graph ### Contribute -Follow instructions for [contributing to cugraph](https://github.com/rapidsai/cugraph/blob/branch-23.10/readme_pages/CONTRIBUTING.md) +Follow instructions for [contributing to cugraph](https://github.com/rapidsai/cugraph/blob/branch-23.12 and [building from source](https://docs.rapids.ai/api/cugraph/stable/installation/source_build/), then build nx-cugraph in develop (i.e., editable) mode: ``` $ ./build.sh nx-cugraph --pydevelop From ef159d71f0dcd2a783d71b3b2cf38a787599b66e Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 28 Sep 2023 13:09:17 -0500 Subject: [PATCH 03/51] Add entry point to tell NetworkX about nx-cugraph without importing it. (#3848) This allows NetworkX docstrings to be updated (among other things). This will have a companion PR in NetworkX. We still need to determine (and agree) on the dict returned by this entry point, and NetworkX doesn't need to use everything I have here. We should probably add a string for `"description"` that gives a very short description of the backend, and maybe `"url"` or `"homepage"` or whatever so online docs can have links. Here's how to use the entry point (Python >= 3.10) after installing it: ```python In [1]: from importlib.metadata import entry_points In [2]: items = entry_points(group="networkx.plugin_info") In [3]: [plugin] = items In [4]: plugin.load()() Out[4]: {'backend_name': 'cugraph', 'project': 'nx-cugraph', 'package': 'nx_cugraph', 'functions': {'betweenness_centrality', 'edge_betweenness_centrality', 'louvain_communities'}, 'extra_docstrings': {'betweenness_centrality': '`weight` parameter is not yet supported.', 'edge_betweenness_centrality': '`weight` parameter is not yet supported.', 'louvain_communities': '`threshold` and `seed` parameters are currently ignored.'}, 'extra_parameters': {'louvain_communities': {'max_level': 'Upper limit of the number of macro-iterations.'}}} ``` CC @rlratzel @betochimas Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/cugraph/pull/3848 --- _nx_cugraph/__init__.py | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 _nx_cugraph/__init__.py diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py new file mode 100644 index 000000000..9b3332106 --- /dev/null +++ b/_nx_cugraph/__init__.py @@ -0,0 +1,88 @@ +# 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. +"""Tell NetworkX about the cugraph backend. This file can update itself: + +$ make plugin-info # Recommended method for development + +or + +$ python _nx_cugraph/__init__.py +""" + +# Entries between BEGIN and END are automatically generated +_info = { + "backend_name": "cugraph", + "project": "nx-cugraph", + "package": "nx_cugraph", + "url": "https://github.com/rapidsai/cugraph/tree/branch-23.10/python/nx-cugraph", + "short_summary": "GPU-accelerated backend.", + # "description": "TODO", + "functions": { + # BEGIN: functions + "betweenness_centrality", + "edge_betweenness_centrality", + "louvain_communities", + # END: functions + }, + "extra_docstrings": { + # BEGIN: extra_docstrings + "betweenness_centrality": "`weight` parameter is not yet supported.", + "edge_betweenness_centrality": "`weight` parameter is not yet supported.", + "louvain_communities": "`threshold` and `seed` parameters are currently ignored.", + # END: extra_docstrings + }, + "extra_parameters": { + # BEGIN: extra_parameters + "louvain_communities": { + "max_level : int, optional": "Upper limit of the number of macro-iterations.", + }, + # END: extra_parameters + }, +} + + +def get_info(): + """Target of ``networkx.plugin_info`` entry point. + + This tells NetworkX about the cugraph backend without importing nx_cugraph. + """ + # Convert to e.g. `{"functions": {"myfunc": {"extra_docstring": ...}}}` + d = _info.copy() + info_keys = { + "extra_docstrings": "extra_docstring", + "extra_parameters": "extra_parameters", + } + d["functions"] = { + func: { + new_key: vals[func] + for old_key, new_key in info_keys.items() + if func in (vals := d[old_key]) + } + for func in d["functions"] + } + for key in info_keys: + del d[key] + return d + + +__version__ = "23.10.00" + +if __name__ == "__main__": + from pathlib import Path + + from _nx_cugraph.core import main + + filepath = Path(__file__) + text = main(filepath) + with filepath.open("w") as f: + f.write(text) From 69e1a021356fe325b9971443f793b4a6403094af Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 3 Oct 2023 16:50:10 -0500 Subject: [PATCH 04/51] nx-cugraph: handle louvain with isolated nodes (#3897) This handles isolated nodes in `louvain_communities` similar to what is done in #3886. This is expected to be a temporary fix until pylibcugraph can handle isolated nodes. As a bonus, I added `isolates` algorithm :tada: CC @naimnv @rlratzel Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3897 --- _nx_cugraph/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 9b3332106..ebd13dade 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -31,20 +31,23 @@ # BEGIN: functions "betweenness_centrality", "edge_betweenness_centrality", + "is_isolate", + "isolates", "louvain_communities", + "number_of_isolates", # END: functions }, "extra_docstrings": { # BEGIN: extra_docstrings "betweenness_centrality": "`weight` parameter is not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported.", - "louvain_communities": "`threshold` and `seed` parameters are currently ignored.", + "louvain_communities": "`seed` parameter is currently ignored.", # END: extra_docstrings }, "extra_parameters": { # BEGIN: extra_parameters "louvain_communities": { - "max_level : int, optional": "Upper limit of the number of macro-iterations.", + "max_level : int, optional": "Upper limit of the number of macro-iterations (max: 500).", }, # END: extra_parameters }, From fd7f95570b99546c7fb1a81918ddfb5d669d0619 Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:18:24 -0500 Subject: [PATCH 05/51] Adds benchmarks for `nx-cugraph` (#3854) closes rapidsai/graph_dl#299 This PR adds new benchmarks for `nx-cugraph` which can be used to compare performance for NetworkX with and without the `cugraph` backend. These benchmarks depend on `pytest`, `pytest-benchmark`, `networkx>=3.0`, `cugraph` (only for the Dataset APIs), and `nx-cugraph` Some results can be seen here: ![image](https://github.com/rapidsai/cugraph/assets/3039903/d595eb3f-2ae6-4b2e-a0b1-a0f0bcb050a8) ![image](https://github.com/rapidsai/cugraph/assets/3039903/3ca367b4-14b8-4673-91d2-f83a947163e7) ### Other changes: * `black` is now run on all python sources under `benchmarks`, which resulted in several format-only changes. * Several other updates to versions, etc. were applied to various .yaml files in order to resolve CI errors. * Merged in changes from [jnke2016/branch-23.10_increase-timeout](https://github.com/rapidsai/cugraph/pull/3854/commits/cbdbd8a6d22903f251c64b1b0321ba41ec03fcb3) to get changes needed to fix dask CI failure. Authors: - Rick Ratzel (https://github.com/rlratzel) - Joseph Nke (https://github.com/jnke2016) - AJ Schmidt (https://github.com/ajschmidt8) - Naim (https://github.com/naimnv) - Seunghwa Kang (https://github.com/seunghwak) - https://github.com/lmeyerov - Erik Welch (https://github.com/eriknw) - Alex Barghi (https://github.com/alexbarghi-nv) - Vyas Ramasubramani (https://github.com/vyasr) - Divye Gala (https://github.com/divyegala) - Tingyu Wang (https://github.com/tingyu66) - Chuck Hastings (https://github.com/ChuckHastings) - ralph (https://github.com/nv-rliu) - Paul Taylor (https://github.com/trxcllnt) Approvers: - Erik Welch (https://github.com/eriknw) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/cugraph/pull/3854 --- _nx_cugraph/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 9b3332106..ba7fe5e91 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -75,7 +75,7 @@ def get_info(): return d -__version__ = "23.10.00" +__version__ = "23.12.00" if __name__ == "__main__": from pathlib import Path From 73c505823df033b0bb30b78bbcdfda7fc47fad85 Mon Sep 17 00:00:00 2001 From: Ray Douglass <3107146+raydouglass@users.noreply.github.com> Date: Tue, 17 Oct 2023 06:28:14 -0400 Subject: [PATCH 06/51] Updates to 23.12 (#3905) A couple PRs were merged after `branch-23.12` was created and contained RAPIDS versions that need to be updated in `branch-23.12`. Ref: - https://github.com/rapidsai/cugraph/pull/3838 - https://github.com/rapidsai/cugraph/pull/3852 Authors: - Ray Douglass (https://github.com/raydouglass) - Rick Ratzel (https://github.com/rlratzel) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Brad Rees (https://github.com/BradReesWork) URL: https://github.com/rapidsai/cugraph/pull/3905 --- _nx_cugraph/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 227caea29..886d7a19f 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -24,7 +24,7 @@ "backend_name": "cugraph", "project": "nx-cugraph", "package": "nx_cugraph", - "url": "https://github.com/rapidsai/cugraph/tree/branch-23.10/python/nx-cugraph", + "url": "https://github.com/rapidsai/cugraph/tree/branch-23.12/python/nx-cugraph", "short_summary": "GPU-accelerated backend.", # "description": "TODO", "functions": { From b53448efcd6822084d14028147cfd725e5a16952 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 25 Oct 2023 16:16:00 -0500 Subject: [PATCH 07/51] nx-cugraph: add k_truss and degree centralities (#3945) New algorithms: - `degree_centrality` - `in_degree_centrality` - `k_truss` - `number_of_selfloops` - `out_degree_centrality` Also, rename `row_indices, col_indices` to `src_indices, dst_indices` Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3945 --- _nx_cugraph/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 886d7a19f..965b5b232 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -30,11 +30,16 @@ "functions": { # BEGIN: functions "betweenness_centrality", + "degree_centrality", "edge_betweenness_centrality", + "in_degree_centrality", "is_isolate", "isolates", + "k_truss", "louvain_communities", "number_of_isolates", + "number_of_selfloops", + "out_degree_centrality", # END: functions }, "extra_docstrings": { From dd4ab33528c3cb4874e31b34f7640399fe2e1928 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 31 Oct 2023 14:10:20 -0500 Subject: [PATCH 08/51] Add many graph generators to nx-cugraph (#3954) Also, better handle dtypes for edge values passed to pylibcugraph, which only takes float32 and float64 atm. I also defined `index_dtype` (currently int32) to globally control the dtype of indices. Authors: - Erik Welch (https://github.com/eriknw) - Ralph Liu (https://github.com/nv-rliu) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3954 --- _nx_cugraph/__init__.py | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 965b5b232..af1df0464 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -29,23 +29,68 @@ # "description": "TODO", "functions": { # BEGIN: functions + "barbell_graph", "betweenness_centrality", + "bull_graph", + "caveman_graph", + "chvatal_graph", + "circular_ladder_graph", + "complete_bipartite_graph", + "complete_graph", + "complete_multipartite_graph", + "cubical_graph", + "cycle_graph", + "davis_southern_women_graph", "degree_centrality", + "desargues_graph", + "diamond_graph", + "dodecahedral_graph", "edge_betweenness_centrality", + "empty_graph", + "florentine_families_graph", + "from_pandas_edgelist", + "from_scipy_sparse_array", + "frucht_graph", + "heawood_graph", + "house_graph", + "house_x_graph", + "icosahedral_graph", "in_degree_centrality", "is_isolate", "isolates", "k_truss", + "karate_club_graph", + "krackhardt_kite_graph", + "ladder_graph", + "les_miserables_graph", + "lollipop_graph", "louvain_communities", + "moebius_kantor_graph", + "null_graph", "number_of_isolates", "number_of_selfloops", + "octahedral_graph", "out_degree_centrality", + "pappus_graph", + "path_graph", + "petersen_graph", + "sedgewick_maze_graph", + "star_graph", + "tadpole_graph", + "tetrahedral_graph", + "trivial_graph", + "truncated_cube_graph", + "truncated_tetrahedron_graph", + "turan_graph", + "tutte_graph", + "wheel_graph", # END: functions }, "extra_docstrings": { # BEGIN: extra_docstrings "betweenness_centrality": "`weight` parameter is not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported.", + "from_pandas_edgelist": "cudf.DataFrame inputs also supported.", "louvain_communities": "`seed` parameter is currently ignored.", # END: extra_docstrings }, From e8e42f11dbb6131d9269605a5fa55d80dcfd7205 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 31 Oct 2023 17:50:52 -0500 Subject: [PATCH 09/51] nx-cugraph: add CC for undirected graphs to fix k-truss (#3965) Fixes #3963 and add `connected_components`, `is_connected`, `node_connected_component`, and `number_connected_components`. Also updated `_groupby` to handle groups that are not consecutive integers starting with 0. Also, `plc.weakly_connected_components` does not handle isolated nodes well, and I needed to handle this at the Python layer as was done in #3897 Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3965 --- _nx_cugraph/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index af1df0464..8ef976aab 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -38,6 +38,7 @@ "complete_bipartite_graph", "complete_graph", "complete_multipartite_graph", + "connected_components", "cubical_graph", "cycle_graph", "davis_southern_women_graph", @@ -56,6 +57,7 @@ "house_x_graph", "icosahedral_graph", "in_degree_centrality", + "is_connected", "is_isolate", "isolates", "k_truss", @@ -66,7 +68,9 @@ "lollipop_graph", "louvain_communities", "moebius_kantor_graph", + "node_connected_component", "null_graph", + "number_connected_components", "number_of_isolates", "number_of_selfloops", "octahedral_graph", @@ -91,6 +95,10 @@ "betweenness_centrality": "`weight` parameter is not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported.", + "k_truss": ( + "Currently raises `NotImplementedError` for graphs with more than one connected\n" + "component when k >= 3. We expect to fix this soon." + ), "louvain_communities": "`seed` parameter is currently ignored.", # END: extra_docstrings }, From c06ef826f8cb39ca628b560f3d8f1d38429c95ee Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:51:33 -0600 Subject: [PATCH 10/51] Updates README file to include nx-cugraph user documentation, adds nx-cugraph to main README (#3984) * Updates the nx-cugraph README file to include nx-cugraph user documentation * Adds nx-cugraph and new News section to main README * Updates software strack diagram to remove DGL and PyG since they are not currently using PropertyGraph or cugraph-service Authors: - Rick Ratzel (https://github.com/rlratzel) - Ralph Liu (https://github.com/nv-rliu) Approvers: - Brad Rees (https://github.com/BradReesWork) --- README.md | 135 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 119 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index ab267e5a7..148fb2f09 100644 --- a/README.md +++ b/README.md @@ -2,31 +2,134 @@ ## Description [RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/reference/classes/index.html#backends) -with minimal dependencies (`networkx`, `cupy`, and `pylibcugraph`) to run graph algorithms on the GPU. +to run supported algorithms with GPU acceleration. -### Contribute +## System Requirements -Follow instructions for [contributing to cugraph](https://github.com/rapidsai/cugraph/blob/branch-23.12 -and [building from source](https://docs.rapids.ai/api/cugraph/stable/installation/source_build/), then build nx-cugraph in develop (i.e., editable) mode: -``` -$ ./build.sh nx-cugraph --pydevelop -``` +nx-cugraph requires the following: + + * NVIDIA GPU, Pascal architecture or later + * CUDA 11.2, 11.4, 11.5, 11.8, or 12.0 + * Python versions 3.9, 3.10, or 3.11 + * NetworkX >= version 3.2 -### Run tests +More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req).. -Run nx-cugraph tests from `cugraph/python/nx-cugraph` directory: +## Installation + +nx-cugraph can be installed using either conda or pip. + +### conda ``` -$ pytest +conda install -c rapidsai-nightly -c conda-forge -c nvidia nx-cugraph ``` -Run nx-cugraph benchmarks: +### pip ``` -$ pytest --bench +python -m pip install nx-cugraph-cu11 --extra-index-url https://pypi.nvidia.com ``` -Run networkx tests (requires networkx version 3.2): +Notes: + + * Nightly wheel builds will not be available until the 23.12 release, therefore the index URL for the stable release version is being used in the pip install command above. + * Additional information relevant to installing any RAPIDS package can be found [here](https://rapids.ai/#quick-start). + +## Enabling nx-cugraph + +NetworkX will use nx-cugraph as the graph analytics backend if any of the +following are are used: + +### `NETWORKX_AUTOMATIC_BACKENDS` environment variable. +The `NETWORKX_AUTOMATIC_BACKENDS` environment variable can be used to have NetworkX automatically dispatch to specified backends an API is called that the backend supports. +Set `NETWORKX_AUTOMATIC_BACKENDS=cugraph` to use nx-cugraph to GPU accelerate supported APIs with no code changes. +Example: ``` -$ ./run_nx_tests.sh +bash> NETWORKX_AUTOMATIC_BACKENDS=cugraph python my_networkx_script.py ``` -Additional arguments may be passed to pytest such as: + +### `backend=` keyword argument +To explicitly specify a particular backend for an API, use the `backend=` +keyword argument. This argument takes precedence over the +`NETWORKX_AUTOMATIC_BACKENDS` environment variable. This requires anyone +running code that uses the `backend=` keyword argument to have the specified +backend installed. + +Example: ``` -$ ./run_nx_tests.sh -x --sw -k betweenness +nx.betweenness_centrality(cit_patents_graph, k=k, backend="cugraph") ``` + +### Type-based dispatching + +NetworkX also supports automatically dispatching to backends associated with +specific graph types. Like the `backend=` keyword argument example above, this +requires the user to write code for a specific backend, and therefore requires +the backend to be installed, but has the advantage of ensuring a particular +behavior without the potential for runtime conversions. + +To use type-based dispatching with nx-cugraph, the user must import the backend +directly in their code to access the utilities provided to create a Graph +instance specifically for the nx-cugraph backend. + +Example: +``` +import networkx as nx +import nx_cugraph as nxcg + +G = nx.Graph() +... +nxcg_G = nxcg.from_networkx(G) # conversion happens once here +nx.betweenness_centrality(nxcg_G, k=1000) # nxcg Graph type causes cugraph backend + # to be used, no conversion necessary +``` + +## Supported Algorithms + +The nx-cugraph backend to NetworkX connects +[pylibcugraph](../../readme_pages/pylibcugraph.md) (cuGraph's low-level python +interface to its CUDA-based graph analytics library) and +[CuPy](https://cupy.dev/) (a GPU-accelerated array library) to NetworkX's +familiar and easy-to-use API. + +Below is the list of algorithms (many listed using pylibcugraph names), +available today in pylibcugraph or implemented using CuPy, that are or will be +supported in nx-cugraph. + +| feature/algo | release/target version | +| ----- | ----- | +| analyze_clustering_edge_cut | ? | +| analyze_clustering_modularity | ? | +| analyze_clustering_ratio_cut | ? | +| balanced_cut_clustering | ? | +| betweenness_centrality | 23.10 | +| bfs | ? | +| core_number | ? | +| degree_centrality | 23.12 | +| ecg | ? | +| edge_betweenness_centrality | 23.10 | +| ego_graph | ? | +| eigenvector_centrality | 23.12 | +| get_two_hop_neighbors | ? | +| hits | 23.12 | +| in_degree_centrality | 23.12 | +| induced_subgraph | ? | +| jaccard_coefficients | ? | +| katz_centrality | 23.12 | +| k_core | ? | +| k_truss_subgraph | 23.12 | +| leiden | ? | +| louvain | 23.10 | +| node2vec | ? | +| out_degree_centrality | 23.12 | +| overlap_coefficients | ? | +| pagerank | 23.12 | +| personalized_pagerank | ? | +| sorensen_coefficients | ? | +| spectral_modularity_maximization | ? | +| sssp | 23.12 | +| strongly_connected_components | ? | +| triangle_count | ? | +| uniform_neighbor_sample | ? | +| uniform_random_walks | ? | +| weakly_connected_components | ? | + +To request nx-cugraph backend support for a NetworkX API that is not listed +above, visit the [cuGraph GitHub repo](https://github.com/rapidsai/cugraph). From acbece75447f550163695d5258b58eb109eab14c Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Wed, 8 Nov 2023 11:07:29 -0600 Subject: [PATCH 11/51] Fixes typos, updates link to NX backend docs. (#3989) * Fixes typos (repeated word, extra periods) * Updates link to the current docs on NetworkX backends Authors: - Rick Ratzel (https://github.com/rlratzel) Approvers: - Ray Douglass (https://github.com/raydouglass) --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 148fb2f09..273a6112d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # nx-cugraph ## Description -[RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/reference/classes/index.html#backends) +[RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/reference/utils.html#backends) to run supported algorithms with GPU acceleration. ## System Requirements @@ -13,7 +13,7 @@ nx-cugraph requires the following: * Python versions 3.9, 3.10, or 3.11 * NetworkX >= version 3.2 -More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req).. +More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req). ## Installation @@ -35,7 +35,7 @@ Notes: ## Enabling nx-cugraph NetworkX will use nx-cugraph as the graph analytics backend if any of the -following are are used: +following are used: ### `NETWORKX_AUTOMATIC_BACKENDS` environment variable. The `NETWORKX_AUTOMATIC_BACKENDS` environment variable can be used to have NetworkX automatically dispatch to specified backends an API is called that the backend supports. From ad019ef89c6206f2c5901d0be08b53a1ad63acef Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Tue, 14 Nov 2023 09:29:03 -0600 Subject: [PATCH 12/51] Adds update-version.sh support for proper versioning to cu version suffix pacakges and nx-cugraph meta-data files. (#3994) Adds `update-version.sh` support for: * nx-cugraph meta-data files * `cugraph-pyg`, `cugraph-dgl` env yaml files * `*-cu11`, `*-cu12` wheel dependencies in dependencies.yaml Authors: - Rick Ratzel (https://github.com/rlratzel) Approvers: - Alex Barghi (https://github.com/alexbarghi-nv) - Brad Rees (https://github.com/BradReesWork) - Ray Douglass (https://github.com/raydouglass) --- _nx_cugraph/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 8ef976aab..26638d1e7 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -136,6 +136,7 @@ def get_info(): return d +# FIXME: can this use the standard VERSION file and update mechanism? __version__ = "23.12.00" if __name__ == "__main__": From 095f6f3f7ac7ff6b85b951d04ab85617099561e2 Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Tue, 14 Nov 2023 11:31:50 -0500 Subject: [PATCH 13/51] v24.02 Updates [skip ci] --- _nx_cugraph/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 26638d1e7..2e5a16aa4 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -24,7 +24,7 @@ "backend_name": "cugraph", "project": "nx-cugraph", "package": "nx_cugraph", - "url": "https://github.com/rapidsai/cugraph/tree/branch-23.12/python/nx-cugraph", + "url": "https://github.com/rapidsai/cugraph/tree/branch-24.02/python/nx-cugraph", "short_summary": "GPU-accelerated backend.", # "description": "TODO", "functions": { @@ -137,7 +137,7 @@ def get_info(): # FIXME: can this use the standard VERSION file and update mechanism? -__version__ = "23.12.00" +__version__ = "24.02.00" if __name__ == "__main__": from pathlib import Path From 9f8bdb2fac0b5e20aa04995a91e7949d954e17ae Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 20 Nov 2023 17:36:50 -0600 Subject: [PATCH 14/51] nx-cugraph: add SSSP (unweighted) (#3976) There are many more traversal algorithms to implement, but these get us started! Authors: - Erik Welch (https://github.com/eriknw) - Brad Rees (https://github.com/BradReesWork) - Rick Ratzel (https://github.com/rlratzel) Approvers: - Brad Rees (https://github.com/BradReesWork) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3976 --- _nx_cugraph/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 26638d1e7..910db1bc3 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -79,6 +79,8 @@ "path_graph", "petersen_graph", "sedgewick_maze_graph", + "single_source_shortest_path_length", + "single_target_shortest_path_length", "star_graph", "tadpole_graph", "tetrahedral_graph", From 0b1db0f9b1db747df662936e1cc0a82a36f32598 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 21 Nov 2023 20:44:54 -0600 Subject: [PATCH 15/51] nx-cugraph: add `eigenvector_centrality`, `katz_centrality`, `hits`, `pagerank` (#3968) Add `eigenvector_centrality`, `katz_centrality`, and `hits`. I may add pagerank next. Authors: - Erik Welch (https://github.com/eriknw) - Ralph Liu (https://github.com/nv-rliu) - Naim (https://github.com/naimnv) - Rick Ratzel (https://github.com/rlratzel) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/3968 --- _nx_cugraph/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 910db1bc3..ef5f8f3fc 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -47,12 +47,14 @@ "diamond_graph", "dodecahedral_graph", "edge_betweenness_centrality", + "eigenvector_centrality", "empty_graph", "florentine_families_graph", "from_pandas_edgelist", "from_scipy_sparse_array", "frucht_graph", "heawood_graph", + "hits", "house_graph", "house_x_graph", "icosahedral_graph", @@ -62,6 +64,7 @@ "isolates", "k_truss", "karate_club_graph", + "katz_centrality", "krackhardt_kite_graph", "ladder_graph", "les_miserables_graph", @@ -75,6 +78,7 @@ "number_of_selfloops", "octahedral_graph", "out_degree_centrality", + "pagerank", "pappus_graph", "path_graph", "petersen_graph", @@ -96,19 +100,36 @@ # BEGIN: extra_docstrings "betweenness_centrality": "`weight` parameter is not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported.", + "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported.", "k_truss": ( "Currently raises `NotImplementedError` for graphs with more than one connected\n" "component when k >= 3. We expect to fix this soon." ), + "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.", "louvain_communities": "`seed` parameter is currently ignored.", + "pagerank": "`dangling` parameter is not supported, but it is checked for validity.", # END: extra_docstrings }, "extra_parameters": { # BEGIN: extra_parameters + "eigenvector_centrality": { + "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", + }, + "hits": { + "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", + 'weight : string or None, optional (default="weight")': "The edge attribute to use as the edge weight.", + }, + "katz_centrality": { + "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", + }, "louvain_communities": { + "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", "max_level : int, optional": "Upper limit of the number of macro-iterations (max: 500).", }, + "pagerank": { + "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", + }, # END: extra_parameters }, } From c582d070062bba22bdc4a84c50f038eb0ecc9dca Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Wed, 22 Nov 2023 12:12:50 -0600 Subject: [PATCH 16/51] Adds missing connected_components algo to table. (#4019) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 273a6112d..f6a9aac10 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ supported in nx-cugraph. | balanced_cut_clustering | ? | | betweenness_centrality | 23.10 | | bfs | ? | +| connected_components | 23.12 | | core_number | ? | | degree_centrality | 23.12 | | ecg | ? | From 4545e3f080cfcb2cd4858fe80af563b7746de29a Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 20 Dec 2023 19:18:38 -0600 Subject: [PATCH 17/51] nx-cugraph: add `ancestors` and `descendants` (#4029) Authors: - Erik Welch (https://github.com/eriknw) Approvers: - AJ Schmidt (https://github.com/ajschmidt8) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4029 --- _nx_cugraph/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 1fd436bb8..d02c9c3e9 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -29,8 +29,14 @@ # "description": "TODO", "functions": { # BEGIN: functions + "ancestors", "barbell_graph", "betweenness_centrality", + "bfs_edges", + "bfs_layers", + "bfs_predecessors", + "bfs_successors", + "bfs_tree", "bull_graph", "caveman_graph", "chvatal_graph", @@ -44,6 +50,8 @@ "davis_southern_women_graph", "degree_centrality", "desargues_graph", + "descendants", + "descendants_at_distance", "diamond_graph", "dodecahedral_graph", "edge_betweenness_centrality", @@ -53,6 +61,7 @@ "from_pandas_edgelist", "from_scipy_sparse_array", "frucht_graph", + "generic_bfs_edges", "heawood_graph", "hits", "house_graph", @@ -99,9 +108,14 @@ "extra_docstrings": { # BEGIN: extra_docstrings "betweenness_centrality": "`weight` parameter is not yet supported.", + "bfs_edges": "`sort_neighbors` parameter is not yet supported.", + "bfs_predecessors": "`sort_neighbors` parameter is not yet supported.", + "bfs_successors": "`sort_neighbors` parameter is not yet supported.", + "bfs_tree": "`sort_neighbors` parameter is not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported.", "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported.", + "generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.", "k_truss": ( "Currently raises `NotImplementedError` for graphs with more than one connected\n" "component when k >= 3. We expect to fix this soon." From b453e00db437dd259ebc6d9459d730840ec61ea3 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 16 Jan 2024 09:39:31 -0600 Subject: [PATCH 18/51] nx-cugraph: PLC now handles isolated nodes; clean up our workarounds (#4092) Hooray for removing and cleaning code! Tests also added (we already tested isolated nodes for Louvain). nx-cugraph was updated to handle isolated nodes by passing the node set to PLC in #4077 Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4092 --- _nx_cugraph/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index d02c9c3e9..4e869c76b 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, 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 @@ -107,21 +107,21 @@ }, "extra_docstrings": { # BEGIN: extra_docstrings - "betweenness_centrality": "`weight` parameter is not yet supported.", + "betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "bfs_edges": "`sort_neighbors` parameter is not yet supported.", "bfs_predecessors": "`sort_neighbors` parameter is not yet supported.", "bfs_successors": "`sort_neighbors` parameter is not yet supported.", "bfs_tree": "`sort_neighbors` parameter is not yet supported.", - "edge_betweenness_centrality": "`weight` parameter is not yet supported.", + "edge_betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", - "from_pandas_edgelist": "cudf.DataFrame inputs also supported.", + "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.", "generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.", "k_truss": ( "Currently raises `NotImplementedError` for graphs with more than one connected\n" "component when k >= 3. We expect to fix this soon." ), "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.", - "louvain_communities": "`seed` parameter is currently ignored.", + "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.", "pagerank": "`dangling` parameter is not supported, but it is checked for validity.", # END: extra_docstrings }, From ee044a82caa094a6024abf9067413cf588ce4b75 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 16 Jan 2024 19:39:48 -0600 Subject: [PATCH 19/51] nx-cugraph: add weakly connected components (#4071) This doesn't currently work, because `plc.weakly_connected_components` only works on symmetric graphs (so it's not actually performing wcc now is it?): > RuntimeError: non-success value returned from cugraph_weakly_connected_components: CUGRAPH_UNKNOWN_ERROR cuGraph failure at file=[...]/cugraph/cpp/src/components/weakly_connected_components_impl.cuh line=283: Invalid input argument: input graph should be symmetric for weakly connected components. _These are high-priority algorithms for `nx-cugraph`, because they are widely used by networkx dependents._ Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4071 --- _nx_cugraph/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 4e869c76b..d9b997411 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -70,6 +70,8 @@ "in_degree_centrality", "is_connected", "is_isolate", + "is_strongly_connected", + "is_weakly_connected", "isolates", "k_truss", "karate_club_graph", @@ -85,6 +87,8 @@ "number_connected_components", "number_of_isolates", "number_of_selfloops", + "number_strongly_connected_components", + "number_weakly_connected_components", "octahedral_graph", "out_degree_centrality", "pagerank", @@ -95,6 +99,7 @@ "single_source_shortest_path_length", "single_target_shortest_path_length", "star_graph", + "strongly_connected_components", "tadpole_graph", "tetrahedral_graph", "trivial_graph", @@ -102,6 +107,7 @@ "truncated_tetrahedron_graph", "turan_graph", "tutte_graph", + "weakly_connected_components", "wheel_graph", # END: functions }, From a606ee3be5b458454ac4fb952779ccb6dc75304d Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 18 Jan 2024 05:22:11 -0600 Subject: [PATCH 20/51] `nx-cugraph`: add `to_undirected` method; add reciprocity algorithms (#4063) Getting `G.to_undirected` to work was more involved than I expected, but at least we got two algorithms "for free" out of the effort! We raise `NotImplementedError` for `multidigraph.to_undirected()` for now. I would say that understanding the reciprocity algorithms is the first step to understanding `to_undirected`. Authors: - Erik Welch (https://github.com/eriknw) - Rick Ratzel (https://github.com/rlratzel) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4063 --- _nx_cugraph/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index d9b997411..69320e6b5 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -91,10 +91,12 @@ "number_weakly_connected_components", "octahedral_graph", "out_degree_centrality", + "overall_reciprocity", "pagerank", "pappus_graph", "path_graph", "petersen_graph", + "reciprocity", "sedgewick_maze_graph", "single_source_shortest_path_length", "single_target_shortest_path_length", From 1bca3c95777797a315208848500bc8435e69945a Mon Sep 17 00:00:00 2001 From: Ray Douglass Date: Thu, 18 Jan 2024 14:59:02 -0500 Subject: [PATCH 21/51] DOC v24.04 Updates [skip ci] --- _nx_cugraph/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 69320e6b5..3e30bb451 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -24,7 +24,7 @@ "backend_name": "cugraph", "project": "nx-cugraph", "package": "nx_cugraph", - "url": "https://github.com/rapidsai/cugraph/tree/branch-24.02/python/nx-cugraph", + "url": "https://github.com/rapidsai/cugraph/tree/branch-24.04/python/nx-cugraph", "short_summary": "GPU-accelerated backend.", # "description": "TODO", "functions": { @@ -182,7 +182,7 @@ def get_info(): # FIXME: can this use the standard VERSION file and update mechanism? -__version__ = "24.02.00" +__version__ = "24.04.00" if __name__ == "__main__": from pathlib import Path From 129b6de7ae870d78302072e589746947b42652e8 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 19 Jan 2024 09:15:36 -0600 Subject: [PATCH 22/51] nx-cugraph: add triangles and clustering algorithms (#4093) NetworkX tests are somewhat underspecified regarding how to handle self-loops for these algorithms. Also, I'm not sure if transitivity is supposed to work on directed graphs. Once #4071 is merged, it should be easy to add `is_bipartite` function (and maybe others?). Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4093 --- _nx_cugraph/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 69320e6b5..5bfbf082c 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -30,6 +30,7 @@ "functions": { # BEGIN: functions "ancestors", + "average_clustering", "barbell_graph", "betweenness_centrality", "bfs_edges", @@ -41,6 +42,7 @@ "caveman_graph", "chvatal_graph", "circular_ladder_graph", + "clustering", "complete_bipartite_graph", "complete_graph", "complete_multipartite_graph", @@ -68,6 +70,7 @@ "house_x_graph", "icosahedral_graph", "in_degree_centrality", + "is_bipartite", "is_connected", "is_isolate", "is_strongly_connected", @@ -104,6 +107,8 @@ "strongly_connected_components", "tadpole_graph", "tetrahedral_graph", + "transitivity", + "triangles", "trivial_graph", "truncated_cube_graph", "truncated_tetrahedron_graph", @@ -115,11 +120,13 @@ }, "extra_docstrings": { # BEGIN: extra_docstrings + "average_clustering": "Directed graphs and `weight` parameter are not yet supported.", "betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "bfs_edges": "`sort_neighbors` parameter is not yet supported.", "bfs_predecessors": "`sort_neighbors` parameter is not yet supported.", "bfs_successors": "`sort_neighbors` parameter is not yet supported.", "bfs_tree": "`sort_neighbors` parameter is not yet supported.", + "clustering": "Directed graphs and `weight` parameter are not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.", @@ -131,6 +138,7 @@ "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.", "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.", "pagerank": "`dangling` parameter is not supported, but it is checked for validity.", + "transitivity": "Directed graphs are not yet supported.", # END: extra_docstrings }, "extra_parameters": { From c991da09ecc86c9bf1fcf0bf7e75fd74d525620f Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Fri, 19 Jan 2024 12:46:12 -0600 Subject: [PATCH 23/51] nx-cugraph: add `core_number` (undirected graphs only) (#4100) Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4100 --- _nx_cugraph/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 5bfbf082c..8deac55f4 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -47,6 +47,7 @@ "complete_graph", "complete_multipartite_graph", "connected_components", + "core_number", "cubical_graph", "cycle_graph", "davis_southern_women_graph", @@ -127,6 +128,7 @@ "bfs_successors": "`sort_neighbors` parameter is not yet supported.", "bfs_tree": "`sort_neighbors` parameter is not yet supported.", "clustering": "Directed graphs and `weight` parameter are not yet supported.", + "core_number": "Directed graphs are not yet supported.", "edge_betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.", From e9000cb31c3d19643f5b8e12fbd65ccdc83282ae Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 22 Jan 2024 10:31:48 -0600 Subject: [PATCH 24/51] nx-cugraph: add `is_tree`, etc. (#4097) These are now possible b/c we have `connected_components` and `weakly_connected_components` (and their `is_*` equivalents). Authors: - Erik Welch (https://github.com/eriknw) - Rick Ratzel (https://github.com/rlratzel) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4097 --- _nx_cugraph/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 8deac55f4..9bca031a2 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -71,10 +71,14 @@ "house_x_graph", "icosahedral_graph", "in_degree_centrality", + "is_arborescence", "is_bipartite", + "is_branching", "is_connected", + "is_forest", "is_isolate", "is_strongly_connected", + "is_tree", "is_weakly_connected", "isolates", "k_truss", From f0077c16347c2c16efb7744ef9c98a00db392311 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Thu, 25 Jan 2024 14:05:45 -0600 Subject: [PATCH 25/51] nx-cugraph: add `complement` and `reverse` (#4103) We apparently already had `G.reverse()`, which made that function extra easy :) Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4103 --- _nx_cugraph/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 9bca031a2..2f283aa15 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -43,6 +43,7 @@ "chvatal_graph", "circular_ladder_graph", "clustering", + "complement", "complete_bipartite_graph", "complete_graph", "complete_multipartite_graph", @@ -105,6 +106,7 @@ "path_graph", "petersen_graph", "reciprocity", + "reverse", "sedgewick_maze_graph", "single_source_shortest_path_length", "single_target_shortest_path_length", From 85969f06d97f5eff5791cbbc2e06f2cd4995d044 Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:46:22 -0600 Subject: [PATCH 26/51] Removes the `networkx_algorithm` decorator to all SCC functions to disable 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: https://github.com/rapidsai/cugraph/pull/4120 --- _nx_cugraph/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 2f283aa15..8b5c87a63 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -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 @@ -78,7 +82,6 @@ "is_connected", "is_forest", "is_isolate", - "is_strongly_connected", "is_tree", "is_weakly_connected", "isolates", @@ -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", @@ -111,7 +113,6 @@ "single_source_shortest_path_length", "single_target_shortest_path_length", "star_graph", - "strongly_connected_components", "tadpole_graph", "tetrahedral_graph", "transitivity", From 194e416fba98745ae6a1c9d2ed912d77c9686540 Mon Sep 17 00:00:00 2001 From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> Date: Fri, 2 Feb 2024 00:00:18 -0600 Subject: [PATCH 27/51] Updates nx-cugraph README.md with latest algos (#4135) closes #4079 * Updates nx-cugraph `README.md` with latest algos * Adds script to auto-update `README.md` from `nx_cugraph` metadata directly Authors: - Rick Ratzel (https://github.com/rlratzel) - Erik Welch (https://github.com/eriknw) - Brad Rees (https://github.com/BradReesWork) Approvers: - Don Acosta (https://github.com/acostadon) - Erik Welch (https://github.com/eriknw) URL: https://github.com/rapidsai/cugraph/pull/4135 --- README.md | 182 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 140 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index f6a9aac10..5d0554734 100644 --- a/README.md +++ b/README.md @@ -89,48 +89,146 @@ interface to its CUDA-based graph analytics library) and [CuPy](https://cupy.dev/) (a GPU-accelerated array library) to NetworkX's familiar and easy-to-use API. -Below is the list of algorithms (many listed using pylibcugraph names), -available today in pylibcugraph or implemented using CuPy, that are or will be -supported in nx-cugraph. - -| feature/algo | release/target version | -| ----- | ----- | -| analyze_clustering_edge_cut | ? | -| analyze_clustering_modularity | ? | -| analyze_clustering_ratio_cut | ? | -| balanced_cut_clustering | ? | -| betweenness_centrality | 23.10 | -| bfs | ? | -| connected_components | 23.12 | -| core_number | ? | -| degree_centrality | 23.12 | -| ecg | ? | -| edge_betweenness_centrality | 23.10 | -| ego_graph | ? | -| eigenvector_centrality | 23.12 | -| get_two_hop_neighbors | ? | -| hits | 23.12 | -| in_degree_centrality | 23.12 | -| induced_subgraph | ? | -| jaccard_coefficients | ? | -| katz_centrality | 23.12 | -| k_core | ? | -| k_truss_subgraph | 23.12 | -| leiden | ? | -| louvain | 23.10 | -| node2vec | ? | -| out_degree_centrality | 23.12 | -| overlap_coefficients | ? | -| pagerank | 23.12 | -| personalized_pagerank | ? | -| sorensen_coefficients | ? | -| spectral_modularity_maximization | ? | -| sssp | 23.12 | -| strongly_connected_components | ? | -| triangle_count | ? | -| uniform_neighbor_sample | ? | -| uniform_random_walks | ? | -| weakly_connected_components | ? | +Below is the list of algorithms that are currently supported in nx-cugraph. + +### Algorithms + +``` +bipartite + ├─ basic + │ └─ is_bipartite + └─ generators + └─ complete_bipartite_graph +centrality + ├─ betweenness + │ ├─ betweenness_centrality + │ └─ edge_betweenness_centrality + ├─ degree_alg + │ ├─ degree_centrality + │ ├─ in_degree_centrality + │ └─ out_degree_centrality + ├─ eigenvector + │ └─ eigenvector_centrality + └─ katz + └─ katz_centrality +cluster + ├─ average_clustering + ├─ clustering + ├─ transitivity + └─ triangles +community + └─ louvain + └─ louvain_communities +components + ├─ connected + │ ├─ connected_components + │ ├─ is_connected + │ ├─ node_connected_component + │ └─ number_connected_components + └─ weakly_connected + ├─ is_weakly_connected + ├─ number_weakly_connected_components + └─ weakly_connected_components +core + ├─ core_number + └─ k_truss +dag + ├─ ancestors + └─ descendants +isolate + ├─ is_isolate + ├─ isolates + └─ number_of_isolates +link_analysis + ├─ hits_alg + │ └─ hits + └─ pagerank_alg + └─ pagerank +operators + └─ unary + ├─ complement + └─ reverse +reciprocity + ├─ overall_reciprocity + └─ reciprocity +shortest_paths + └─ unweighted + ├─ single_source_shortest_path_length + └─ single_target_shortest_path_length +traversal + └─ breadth_first_search + ├─ bfs_edges + ├─ bfs_layers + ├─ bfs_predecessors + ├─ bfs_successors + ├─ bfs_tree + ├─ descendants_at_distance + └─ generic_bfs_edges +tree + └─ recognition + ├─ is_arborescence + ├─ is_branching + ├─ is_forest + └─ is_tree +``` + +### Generators + +``` +classic + ├─ barbell_graph + ├─ circular_ladder_graph + ├─ complete_graph + ├─ complete_multipartite_graph + ├─ cycle_graph + ├─ empty_graph + ├─ ladder_graph + ├─ lollipop_graph + ├─ null_graph + ├─ path_graph + ├─ star_graph + ├─ tadpole_graph + ├─ trivial_graph + ├─ turan_graph + └─ wheel_graph +community + └─ caveman_graph +small + ├─ bull_graph + ├─ chvatal_graph + ├─ cubical_graph + ├─ desargues_graph + ├─ diamond_graph + ├─ dodecahedral_graph + ├─ frucht_graph + ├─ heawood_graph + ├─ house_graph + ├─ house_x_graph + ├─ icosahedral_graph + ├─ krackhardt_kite_graph + ├─ moebius_kantor_graph + ├─ octahedral_graph + ├─ pappus_graph + ├─ petersen_graph + ├─ sedgewick_maze_graph + ├─ tetrahedral_graph + ├─ truncated_cube_graph + ├─ truncated_tetrahedron_graph + └─ tutte_graph +social + ├─ davis_southern_women_graph + ├─ florentine_families_graph + ├─ karate_club_graph + └─ les_miserables_graph +``` + +### Other + +``` +convert_matrix + ├─ from_pandas_edgelist + └─ from_scipy_sparse_array +``` To request nx-cugraph backend support for a NetworkX API that is not listed above, visit the [cuGraph GitHub repo](https://github.com/rapidsai/cugraph). From 6f81e6a7d4ae4deaf3a1a6e8401db8c5a8079174 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Sun, 25 Feb 2024 18:06:16 -0600 Subject: [PATCH 28/51] Update `louvain_communities` to match NetworkX 3.3 (added max_level) (#4177) We already supported `max_level=`, and this was just upstreamed to networkx here: https://github.com/networkx/networkx/pull/6909 Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4177 --- _nx_cugraph/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index a57c43944..64614fa39 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -164,7 +164,6 @@ }, "louvain_communities": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", - "max_level : int, optional": "Upper limit of the number of macro-iterations (max: 500).", }, "pagerank": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", From 1d6db08a9c1a6d511449870c544779da1da8dcea Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 26 Feb 2024 14:43:25 -0600 Subject: [PATCH 29/51] nx-cugraph: update `get_info` function keys to NetworkX 3.3 (#4192) Updating to match changes from https://github.com/networkx/networkx/pull/7219 Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4192 --- _nx_cugraph/__init__.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 64614fa39..c6c43110a 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -126,8 +126,8 @@ "wheel_graph", # END: functions }, - "extra_docstrings": { - # BEGIN: extra_docstrings + "additional_docs": { + # BEGIN: additional_docs "average_clustering": "Directed graphs and `weight` parameter are not yet supported.", "betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.", "bfs_edges": "`sort_neighbors` parameter is not yet supported.", @@ -148,10 +148,10 @@ "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.", "pagerank": "`dangling` parameter is not supported, but it is checked for validity.", "transitivity": "Directed graphs are not yet supported.", - # END: extra_docstrings + # END: additional_docs }, - "extra_parameters": { - # BEGIN: extra_parameters + "additional_parameters": { + # BEGIN: additional_parameters "eigenvector_centrality": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", }, @@ -168,7 +168,7 @@ "pagerank": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", }, - # END: extra_parameters + # END: additional_parameters }, } @@ -178,20 +178,24 @@ def get_info(): This tells NetworkX about the cugraph backend without importing nx_cugraph. """ - # Convert to e.g. `{"functions": {"myfunc": {"extra_docstring": ...}}}` + # Convert to e.g. `{"functions": {"myfunc": {"additional_docs": ...}}}` d = _info.copy() - info_keys = { - "extra_docstrings": "extra_docstring", - "extra_parameters": "extra_parameters", - } + info_keys = {"additional_docs", "additional_parameters"} d["functions"] = { func: { - new_key: vals[func] - for old_key, new_key in info_keys.items() - if func in (vals := d[old_key]) + info_key: vals[func] + for info_key in info_keys + if func in (vals := d[info_key]) } for func in d["functions"] } + # Add keys for Networkx <3.3 + for func_info in d["functions"].values(): + if "additional_docs" in func_info: + func_info["extra_docstring"] = func_info["additional_docs"] + if "additional_parameters" in func_info: + func_info["extra_parameters"] = func_info["additional_parameters"] + for key in info_keys: del d[key] return d From 77674e6b132408caf6a921175fb65b7647853cd9 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 27 Feb 2024 13:53:26 -0600 Subject: [PATCH 30/51] nx-cugraph: automatically generate trees in README.md (#4156) This updates how we create trees. Also, CI now tests that auto-generated files are up-to-date (not updating these has gotten me a couple of times). Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/cugraph/pull/4156 --- README.md | 270 +++++++++++++++++++++++++++--------------------------- 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/README.md b/README.md index 5d0554734..8201dc34e 100644 --- a/README.md +++ b/README.md @@ -91,144 +91,144 @@ familiar and easy-to-use API. Below is the list of algorithms that are currently supported in nx-cugraph. -### Algorithms - -``` -bipartite - ├─ basic - │ └─ is_bipartite - └─ generators - └─ complete_bipartite_graph -centrality - ├─ betweenness - │ ├─ betweenness_centrality - │ └─ edge_betweenness_centrality - ├─ degree_alg - │ ├─ degree_centrality - │ ├─ in_degree_centrality - │ └─ out_degree_centrality - ├─ eigenvector - │ └─ eigenvector_centrality - └─ katz - └─ katz_centrality -cluster - ├─ average_clustering - ├─ clustering - ├─ transitivity - └─ triangles -community - └─ louvain - └─ louvain_communities -components - ├─ connected - │ ├─ connected_components - │ ├─ is_connected - │ ├─ node_connected_component - │ └─ number_connected_components - └─ weakly_connected - ├─ is_weakly_connected - ├─ number_weakly_connected_components - └─ weakly_connected_components -core - ├─ core_number - └─ k_truss -dag - ├─ ancestors - └─ descendants -isolate - ├─ is_isolate - ├─ isolates - └─ number_of_isolates -link_analysis - ├─ hits_alg - │ └─ hits - └─ pagerank_alg - └─ pagerank -operators - └─ unary - ├─ complement - └─ reverse -reciprocity - ├─ overall_reciprocity - └─ reciprocity -shortest_paths - └─ unweighted - ├─ single_source_shortest_path_length - └─ single_target_shortest_path_length -traversal - └─ breadth_first_search - ├─ bfs_edges - ├─ bfs_layers - ├─ bfs_predecessors - ├─ bfs_successors - ├─ bfs_tree - ├─ descendants_at_distance - └─ generic_bfs_edges -tree - └─ recognition - ├─ is_arborescence - ├─ is_branching - ├─ is_forest - └─ is_tree -``` - -### Generators - -``` -classic - ├─ barbell_graph - ├─ circular_ladder_graph - ├─ complete_graph - ├─ complete_multipartite_graph - ├─ cycle_graph - ├─ empty_graph - ├─ ladder_graph - ├─ lollipop_graph - ├─ null_graph - ├─ path_graph - ├─ star_graph - ├─ tadpole_graph - ├─ trivial_graph - ├─ turan_graph - └─ wheel_graph -community - └─ caveman_graph -small - ├─ bull_graph - ├─ chvatal_graph - ├─ cubical_graph - ├─ desargues_graph - ├─ diamond_graph - ├─ dodecahedral_graph - ├─ frucht_graph - ├─ heawood_graph - ├─ house_graph - ├─ house_x_graph - ├─ icosahedral_graph - ├─ krackhardt_kite_graph - ├─ moebius_kantor_graph - ├─ octahedral_graph - ├─ pappus_graph - ├─ petersen_graph - ├─ sedgewick_maze_graph - ├─ tetrahedral_graph - ├─ truncated_cube_graph - ├─ truncated_tetrahedron_graph - └─ tutte_graph -social - ├─ davis_southern_women_graph - ├─ florentine_families_graph - ├─ karate_club_graph - └─ les_miserables_graph -``` +### [Algorithms](https://networkx.org/documentation/latest/reference/algorithms/index.html) + +
+bipartite
+ ├─ basic
+ │   └─ is_bipartite
+ └─ generators
+     └─ complete_bipartite_graph
+centrality
+ ├─ betweenness
+ │   ├─ betweenness_centrality
+ │   └─ edge_betweenness_centrality
+ ├─ degree_alg
+ │   ├─ degree_centrality
+ │   ├─ in_degree_centrality
+ │   └─ out_degree_centrality
+ ├─ eigenvector
+ │   └─ eigenvector_centrality
+ └─ katz
+     └─ katz_centrality
+cluster
+ ├─ average_clustering
+ ├─ clustering
+ ├─ transitivity
+ └─ triangles
+community
+ └─ louvain
+     └─ louvain_communities
+components
+ ├─ connected
+ │   ├─ connected_components
+ │   ├─ is_connected
+ │   ├─ node_connected_component
+ │   └─ number_connected_components
+ └─ weakly_connected
+     ├─ is_weakly_connected
+     ├─ number_weakly_connected_components
+     └─ weakly_connected_components
+core
+ ├─ core_number
+ └─ k_truss
+dag
+ ├─ ancestors
+ └─ descendants
+isolate
+ ├─ is_isolate
+ ├─ isolates
+ └─ number_of_isolates
+link_analysis
+ ├─ hits_alg
+ │   └─ hits
+ └─ pagerank_alg
+     └─ pagerank
+operators
+ └─ unary
+     ├─ complement
+     └─ reverse
+reciprocity
+ ├─ overall_reciprocity
+ └─ reciprocity
+shortest_paths
+ └─ unweighted
+     ├─ single_source_shortest_path_length
+     └─ single_target_shortest_path_length
+traversal
+ └─ breadth_first_search
+     ├─ bfs_edges
+     ├─ bfs_layers
+     ├─ bfs_predecessors
+     ├─ bfs_successors
+     ├─ bfs_tree
+     ├─ descendants_at_distance
+     └─ generic_bfs_edges
+tree
+ └─ recognition
+     ├─ is_arborescence
+     ├─ is_branching
+     ├─ is_forest
+     └─ is_tree
+
+ +### [Generators](https://networkx.org/documentation/latest/reference/generators.html) + +
+classic
+ ├─ barbell_graph
+ ├─ circular_ladder_graph
+ ├─ complete_graph
+ ├─ complete_multipartite_graph
+ ├─ cycle_graph
+ ├─ empty_graph
+ ├─ ladder_graph
+ ├─ lollipop_graph
+ ├─ null_graph
+ ├─ path_graph
+ ├─ star_graph
+ ├─ tadpole_graph
+ ├─ trivial_graph
+ ├─ turan_graph
+ └─ wheel_graph
+community
+ └─ caveman_graph
+small
+ ├─ bull_graph
+ ├─ chvatal_graph
+ ├─ cubical_graph
+ ├─ desargues_graph
+ ├─ diamond_graph
+ ├─ dodecahedral_graph
+ ├─ frucht_graph
+ ├─ heawood_graph
+ ├─ house_graph
+ ├─ house_x_graph
+ ├─ icosahedral_graph
+ ├─ krackhardt_kite_graph
+ ├─ moebius_kantor_graph
+ ├─ octahedral_graph
+ ├─ pappus_graph
+ ├─ petersen_graph
+ ├─ sedgewick_maze_graph
+ ├─ tetrahedral_graph
+ ├─ truncated_cube_graph
+ ├─ truncated_tetrahedron_graph
+ └─ tutte_graph
+social
+ ├─ davis_southern_women_graph
+ ├─ florentine_families_graph
+ ├─ karate_club_graph
+ └─ les_miserables_graph
+
### Other -``` -convert_matrix - ├─ from_pandas_edgelist - └─ from_scipy_sparse_array -``` +
+convert_matrix
+ ├─ from_pandas_edgelist
+ └─ from_scipy_sparse_array
+
To request nx-cugraph backend support for a NetworkX API that is not listed above, visit the [cuGraph GitHub repo](https://github.com/rapidsai/cugraph). From 27700238fe1190b78eb1b253e455da4850a14120 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 6 Mar 2024 18:33:06 -0600 Subject: [PATCH 31/51] Fix `louvain_communities`, `PropertyGraph`, cudf `column.full`, dgl 2.1.0 CI failures (#4215) * Updates cudf usage in hypergraph to use `cudf.core.column.as_column` instead of the deprecated `cudf.core.column.full` API * Adds code to call louvain using a signature that's compatible with both pre and post NX 3.3 * Adds an upper bound to the DGL version pin to ensure a compatible version is used * Updates a PropertyGraph test to handle minor ordering changes in the result DataFrame * Test matrices starting 24.04 have changed, resulting in an "empty matrix" error when attempting to use the supported combination used for PyG (PyG wheel tests need pytorch with CUDA 12.2 on arm64), so the matrix was simplified to remove the CUDA 11.8 requirement. cc @tingyu66 Authors: - Erik Welch (https://github.com/eriknw) - Naim (https://github.com/naimnv) Approvers: - Rick Ratzel (https://github.com/rlratzel) - Ray Douglass (https://github.com/raydouglass) URL: https://github.com/rapidsai/cugraph/pull/4215 --- _nx_cugraph/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index c6c43110a..b2f13d25f 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -164,6 +164,7 @@ }, "louvain_communities": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", + "max_level : int, optional": "Upper limit of the number of macro-iterations (max: 500).", }, "pagerank": { "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.", From cf5a8223e20ecbd8c2653359b605a7c1ff1c3a30 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 13 Mar 2024 09:18:37 -0500 Subject: [PATCH 32/51] nx-cugraph: add more shortest path algorithms (#4199) This begins by adding more unweighted shortest path algorithms. Next we'll do weighted via `sssp`, then generic. Note that there are some performance improvements that can be made: - add bidirectional search between source and target - for `bidirectional_shortest_path` and `has_path` - alternatively, perform `bfs` from `source` until `target` is reached - run `all_pairs*` in batched groups Authors: - Erik Welch (https://github.com/eriknw) - Ralph Liu (https://github.com/nv-rliu) Approvers: - Brad Rees (https://github.com/BradReesWork) - Rick Ratzel (https://github.com/rlratzel) - Don Acosta (https://github.com/acostadon) URL: https://github.com/rapidsai/cugraph/pull/4199 --- README.md | 25 ++++++++++++++++---- _nx_cugraph/__init__.py | 52 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8201dc34e..1bf310c8c 100644 --- a/README.md +++ b/README.md @@ -95,8 +95,6 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
 bipartite
- ├─ basic
- │   └─ is_bipartite
  └─ generators
      └─ complete_bipartite_graph
 centrality
@@ -152,9 +150,26 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
  ├─ overall_reciprocity
  └─ reciprocity
 shortest_paths
- └─ unweighted
-     ├─ single_source_shortest_path_length
-     └─ single_target_shortest_path_length
+ ├─ generic
+ │   ├─ has_path
+ │   ├─ shortest_path
+ │   └─ shortest_path_length
+ ├─ unweighted
+ │   ├─ all_pairs_shortest_path
+ │   ├─ all_pairs_shortest_path_length
+ │   ├─ bidirectional_shortest_path
+ │   ├─ single_source_shortest_path
+ │   ├─ single_source_shortest_path_length
+ │   ├─ single_target_shortest_path
+ │   └─ single_target_shortest_path_length
+ └─ weighted
+     ├─ all_pairs_bellman_ford_path
+     ├─ all_pairs_bellman_ford_path_length
+     ├─ bellman_ford_path
+     ├─ bellman_ford_path_length
+     ├─ single_source_bellman_ford
+     ├─ single_source_bellman_ford_path
+     └─ single_source_bellman_ford_path_length
 traversal
  └─ breadth_first_search
      ├─ bfs_edges
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index b2f13d25f..bc7f63fcd 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -33,15 +33,22 @@
     # "description": "TODO",
     "functions": {
         # BEGIN: functions
+        "all_pairs_bellman_ford_path",
+        "all_pairs_bellman_ford_path_length",
+        "all_pairs_shortest_path",
+        "all_pairs_shortest_path_length",
         "ancestors",
         "average_clustering",
         "barbell_graph",
+        "bellman_ford_path",
+        "bellman_ford_path_length",
         "betweenness_centrality",
         "bfs_edges",
         "bfs_layers",
         "bfs_predecessors",
         "bfs_successors",
         "bfs_tree",
+        "bidirectional_shortest_path",
         "bull_graph",
         "caveman_graph",
         "chvatal_graph",
@@ -70,6 +77,7 @@
         "from_scipy_sparse_array",
         "frucht_graph",
         "generic_bfs_edges",
+        "has_path",
         "heawood_graph",
         "hits",
         "house_graph",
@@ -77,7 +85,6 @@
         "icosahedral_graph",
         "in_degree_centrality",
         "is_arborescence",
-        "is_bipartite",
         "is_branching",
         "is_connected",
         "is_forest",
@@ -110,7 +117,14 @@
         "reciprocity",
         "reverse",
         "sedgewick_maze_graph",
+        "shortest_path",
+        "shortest_path_length",
+        "single_source_bellman_ford",
+        "single_source_bellman_ford_path",
+        "single_source_bellman_ford_path_length",
+        "single_source_shortest_path",
         "single_source_shortest_path_length",
+        "single_target_shortest_path",
         "single_target_shortest_path_length",
         "star_graph",
         "tadpole_graph",
@@ -128,7 +142,11 @@
     },
     "additional_docs": {
         # BEGIN: additional_docs
+        "all_pairs_bellman_ford_path": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
+        "all_pairs_bellman_ford_path_length": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
         "average_clustering": "Directed graphs and `weight` parameter are not yet supported.",
+        "bellman_ford_path": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
+        "bellman_ford_path_length": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
         "betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.",
         "bfs_edges": "`sort_neighbors` parameter is not yet supported.",
         "bfs_predecessors": "`sort_neighbors` parameter is not yet supported.",
@@ -147,11 +165,28 @@
         "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.",
         "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.",
         "pagerank": "`dangling` parameter is not supported, but it is checked for validity.",
+        "shortest_path": "Negative weights are not yet supported, and method is ununsed.",
+        "shortest_path_length": "Negative weights are not yet supported, and method is ununsed.",
+        "single_source_bellman_ford": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
+        "single_source_bellman_ford_path": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
+        "single_source_bellman_ford_path_length": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
         "transitivity": "Directed graphs are not yet supported.",
         # END: additional_docs
     },
     "additional_parameters": {
         # BEGIN: additional_parameters
+        "all_pairs_bellman_ford_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "all_pairs_bellman_ford_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "bellman_ford_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "bellman_ford_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         "eigenvector_centrality": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
@@ -169,6 +204,21 @@
         "pagerank": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
+        "shortest_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "shortest_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "single_source_bellman_ford": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "single_source_bellman_ford_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "single_source_bellman_ford_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         # END: additional_parameters
     },
 }

From 50e132f3eb203bcc4d5ccf3dbd874631b8936c36 Mon Sep 17 00:00:00 2001
From: Kyle Edwards 
Date: Wed, 13 Mar 2024 15:20:37 -0400
Subject: [PATCH 33/51] Remove hard-coding of RAPIDS version where possible
 (#4217)

* Read `VERSION` file in CMake
* Read `cugraph.__version__` in docs build
* Read `VERSION` file in shell scripts
* Use environment variables in Doxyfile
* Remove updates from `ci/update-version.sh`

Issue: https://github.com/rapidsai/build-planning/issues/15

Authors:
  - Kyle Edwards (https://github.com/KyleFromNVIDIA)

Approvers:
  - Don Acosta (https://github.com/acostadon)
  - Chuck Hastings (https://github.com/ChuckHastings)
  - Brad Rees (https://github.com/BradReesWork)
  - Jake Awe (https://github.com/AyodeAwe)
  - https://github.com/jakirkham

URL: https://github.com/rapidsai/cugraph/pull/4217
---
 _nx_cugraph/__init__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index bc7f63fcd..8c6a65046 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -23,12 +23,18 @@
 $ python _nx_cugraph/__init__.py
 """
 
+from packaging.version import Version
+
+from _nx_cugraph._version import __version__
+
+_nx_cugraph_version = Version(__version__)
+
 # Entries between BEGIN and END are automatically generated
 _info = {
     "backend_name": "cugraph",
     "project": "nx-cugraph",
     "package": "nx_cugraph",
-    "url": "https://github.com/rapidsai/cugraph/tree/branch-24.04/python/nx-cugraph",
+    "url": f"https://github.com/rapidsai/cugraph/tree/branch-{_nx_cugraph_version.major:02}.{_nx_cugraph_version.minor:02}/python/nx-cugraph",
     "short_summary": "GPU-accelerated backend.",
     # "description": "TODO",
     "functions": {
@@ -252,9 +258,6 @@ def get_info():
     return d
 
 
-# FIXME: can this use the standard VERSION file and update mechanism?
-__version__ = "24.04.00"
-
 if __name__ == "__main__":
     from pathlib import Path
 

From 08b08c31ca281fa22f73e522f90d5a83097061ad Mon Sep 17 00:00:00 2001
From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com>
Date: Wed, 13 Mar 2024 17:22:23 -0500
Subject: [PATCH 34/51] Updates nx-cugraph `README` for latest h/w, CUDA,
 python, NX requirements, moves updater to pre-commit (#4225)

* Updates nx-cugraph `README` for latest h/w, CUDA, python, NX requirements
* Moves the call to the nx-cugraph `README` check and auto-updater script from the python CI test script to a pre-commit hook alongside the other codegen calls/checks.  The pre-commit checks are run by the dev at commit-time and by CI as part of the style check job.  This check will only run for changes to files under the `nx-cugraph` subdir.
* Updates the `update_readme.py` script to optionally download the NX `objects.inv` file itself so calling `make` is not required as part of the pre-commit hook.
  * _NOTE: This is less important though, since the pre-commit hook still calls `bash` in order to set the `PYTHONPATH` env var to use the local version of the `update_readme.py` script, which is what I was trying to avoid in the first place. This still has some advantages in making the `update_readme.py` script more usable if the user isn't aware of how to obtain a `objects.inv` file, but feedback is welcome. The hook could also be changed to just call `make` if that ends up being preferred, in which case we'd have to consider if we still want the updates to `update_readme.py` to download the `objects.inv` file itself or not._

Here's the check running as part of the style-check job for this PR:
![image](https://github.com/rapidsai/cugraph/assets/3039903/6a313308-0901-4614-862e-d2596a7754f4)

Authors:
  - Rick Ratzel (https://github.com/rlratzel)
  - Ralph Liu (https://github.com/nv-rliu)

Approvers:
  - Jake Awe (https://github.com/AyodeAwe)
  - Don Acosta (https://github.com/acostadon)
  - Erik Welch (https://github.com/eriknw)

URL: https://github.com/rapidsai/cugraph/pull/4225
---
 README.md               | 20 ++++++++++++++------
 _nx_cugraph/__init__.py | 16 ++++++++++++++++
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 1bf310c8c..77066356a 100644
--- a/README.md
+++ b/README.md
@@ -7,11 +7,10 @@ to run supported algorithms with GPU acceleration.
 ## System Requirements
 
 nx-cugraph requires the following:
-
- * NVIDIA GPU, Pascal architecture or later
+ * NVIDIA GPU, Volta architecture or later, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+
  * CUDA 11.2, 11.4, 11.5, 11.8, or 12.0
- * Python versions 3.9, 3.10, or 3.11
- * NetworkX >= version 3.2
+ * Python version 3.9, 3.10, or 3.11
+ * NetworkX >= version 3.0 (version 3.2 or higher recommended)
 
 More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req).
 
@@ -20,16 +19,25 @@ More details about system requirements can be found in the [RAPIDS System Requir
 nx-cugraph can be installed using either conda or pip.
 
 ### conda
+#### latest nightly version
 ```
 conda install -c rapidsai-nightly -c conda-forge -c nvidia nx-cugraph
 ```
+#### latest stable version
+```
+conda install -c rapidsai -c conda-forge -c nvidia nx-cugraph
+```
 ### pip
+#### latest nightly version
+```
+python -m pip install nx-cugraph-cu11 --extra-index-url https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
+```
+#### latest stable version
 ```
 python -m pip install nx-cugraph-cu11 --extra-index-url https://pypi.nvidia.com
 ```
 Notes:
-
- * Nightly wheel builds will not be available until the 23.12 release, therefore the index URL for the stable release version is being used in the pip install command above.
+ * The pip example above installs for CUDA 11. To install for CUDA 12, replace `-cu11` with `-cu12`
  * Additional information relevant to installing any RAPIDS package can be found [here](https://rapids.ai/#quick-start).
 
 ## Enabling nx-cugraph
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index 8c6a65046..f6e5e3aa5 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -261,6 +261,22 @@ def get_info():
 if __name__ == "__main__":
     from pathlib import Path
 
+    # This script imports nx_cugraph modules, which imports nx_cugraph runtime
+    # dependencies. The modules do not need the runtime deps, so stub them out
+    # to avoid installing them.
+    class Stub:
+        def __getattr__(self, *args, **kwargs):
+            return Stub()
+
+        def __call__(self, *args, **kwargs):
+            return Stub()
+
+    import sys
+
+    sys.modules["cupy"] = Stub()
+    sys.modules["numpy"] = Stub()
+    sys.modules["pylibcugraph"] = Stub()
+
     from _nx_cugraph.core import main
 
     filepath = Path(__file__)

From 3765dbf4fb78ed758b8ca706f31baa6faf08e6df Mon Sep 17 00:00:00 2001
From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com>
Date: Fri, 15 Mar 2024 03:26:26 -0500
Subject: [PATCH 35/51] Removes (unintentional?) runtime dependency on
 `packaging` from nx-cugraph (#4240)

A [recent PR](https://github.com/rapidsai/cugraph/pull/4217) was merged that added `packaging` as a runtime dependency to nx-cugraph.  This PR removes that dependency and manually extracts the `major` and `minor` version numbers instead.

Authors:
  - Rick Ratzel (https://github.com/rlratzel)
  - Erik Welch (https://github.com/eriknw)

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

URL: https://github.com/rapidsai/cugraph/pull/4240
---
 _nx_cugraph/__init__.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index f6e5e3aa5..098de46af 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -23,18 +23,19 @@
 $ python _nx_cugraph/__init__.py
 """
 
-from packaging.version import Version
-
 from _nx_cugraph._version import __version__
 
-_nx_cugraph_version = Version(__version__)
+# This is normally handled by packaging.version.Version, but instead of adding
+# an additional runtime dependency on "packaging", assume __version__ will
+# always be in .. format.
+(_version_major, _version_minor) = __version__.split(".")[:2]
 
 # Entries between BEGIN and END are automatically generated
 _info = {
     "backend_name": "cugraph",
     "project": "nx-cugraph",
     "package": "nx_cugraph",
-    "url": f"https://github.com/rapidsai/cugraph/tree/branch-{_nx_cugraph_version.major:02}.{_nx_cugraph_version.minor:02}/python/nx-cugraph",
+    "url": f"https://github.com/rapidsai/cugraph/tree/branch-{_version_major:0>2}.{_version_minor:0>2}/python/nx-cugraph",
     "short_summary": "GPU-accelerated backend.",
     # "description": "TODO",
     "functions": {

From 932d4991ca194c15eabcbf1390c51bedd90292b3 Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Fri, 15 Mar 2024 13:37:38 -0500
Subject: [PATCH 36/51] nx-cugraph: add `is_negatively_weighted` (#4242)

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

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: https://github.com/rapidsai/cugraph/pull/4242
---
 _nx_cugraph/__init__.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index 098de46af..013f12367 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -96,6 +96,7 @@
         "is_connected",
         "is_forest",
         "is_isolate",
+        "is_negatively_weighted",
         "is_tree",
         "is_weakly_connected",
         "isolates",

From 99415a1fd31db7f5fbea0e70b1a6e43c2207725c Mon Sep 17 00:00:00 2001
From: Rick Ratzel <3039903+rlratzel@users.noreply.github.com>
Date: Tue, 9 Apr 2024 13:10:05 -0500
Subject: [PATCH 37/51] Updates the nx-cugraph README.md with the latest
 upstream URLs (#4321)

This PR updates the nx-cugraph README.md with the latest upstream URLs
by running the `update_readme.py` script on a current `objects.inv` file
downloaded from NetworkX. The latest `objects.inv` file has updated
URLs, which results in links in the README being updated too.

This should resolve style check errors recently seen in [other
PRs](https://github.com/rapidsai/cugraph/pull/4320) due to the upstream
change in `objects.inv` in NetworkX. Since CI runs pre-commit on all
files, this caused the nx-cugraph checks to run on PRs that didn't
change nx-cugraph files.
---
 README.md               | 15 +++++++++------
 _nx_cugraph/__init__.py |  1 -
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 77066356a..75b5c1c5a 100644
--- a/README.md
+++ b/README.md
@@ -106,16 +106,16 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
  └─ generators
      └─ complete_bipartite_graph
 centrality
- ├─ betweenness
+ ├─ betweenness
  │   ├─ betweenness_centrality
  │   └─ edge_betweenness_centrality
- ├─ degree_alg
+ ├─ degree_alg
  │   ├─ degree_centrality
  │   ├─ in_degree_centrality
  │   └─ out_degree_centrality
- ├─ eigenvector
+ ├─ eigenvector
  │   └─ eigenvector_centrality
- └─ katz
+ └─ katz
      └─ katz_centrality
 cluster
  ├─ average_clustering
@@ -126,12 +126,12 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
  └─ louvain
      └─ louvain_communities
 components
- ├─ connected
+ ├─ connected
  │   ├─ connected_components
  │   ├─ is_connected
  │   ├─ node_connected_component
  │   └─ number_connected_components
- └─ weakly_connected
+ └─ weakly_connected
      ├─ is_weakly_connected
      ├─ number_weakly_connected_components
      └─ weakly_connected_components
@@ -248,6 +248,9 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
 ### Other
 
 
+classes
+ └─ function
+     └─ is_negatively_weighted
 convert_matrix
  ├─ from_pandas_edgelist
  └─ from_scipy_sparse_array
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index 013f12367..7a073ffb2 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -207,7 +207,6 @@
         },
         "louvain_communities": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
-            "max_level : int, optional": "Upper limit of the number of macro-iterations (max: 500).",
         },
         "pagerank": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",

From c60782a14ab0d9d370715423a6424836c474df40 Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Thu, 2 May 2024 10:02:01 -0500
Subject: [PATCH 38/51] Update `k_truss` to work with many connected components
 (#4383)

This case is tested by the networkx tests.

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

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: https://github.com/rapidsai/cugraph/pull/4383
---
 _nx_cugraph/__init__.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index 7a073ffb2..edc96983b 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -166,10 +166,6 @@
         "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.",
         "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.",
         "generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.",
-        "k_truss": (
-            "Currently raises `NotImplementedError` for graphs with more than one connected\n"
-            "component when k >= 3. We expect to fix this soon."
-        ),
         "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.",
         "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.",
         "pagerank": "`dangling` parameter is not supported, but it is checked for validity.",

From 9c4ec60485d098f3ab3e87ff5a731702685ed3bb Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Mon, 20 May 2024 19:24:47 -0500
Subject: [PATCH 39/51] nx-cugraph: add `ego_graph` (#4395)

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

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: https://github.com/rapidsai/cugraph/pull/4395
---
 README.md                          |  2 +
 _nx_cugraph/__init__.py            |  5 ++
 nx_cugraph/tests/test_ego_graph.py | 81 ++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+)
 create mode 100644 nx_cugraph/tests/test_ego_graph.py

diff --git a/README.md b/README.md
index 75b5c1c5a..27825585c 100644
--- a/README.md
+++ b/README.md
@@ -216,6 +216,8 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
  └─ wheel_graph
 community
  └─ caveman_graph
+ego
+ └─ ego_graph
 small
  ├─ bull_graph
  ├─ chvatal_graph
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index edc96983b..f57b90eb4 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -77,6 +77,7 @@
         "diamond_graph",
         "dodecahedral_graph",
         "edge_betweenness_centrality",
+        "ego_graph",
         "eigenvector_centrality",
         "empty_graph",
         "florentine_families_graph",
@@ -163,6 +164,7 @@
         "clustering": "Directed graphs and `weight` parameter are not yet supported.",
         "core_number": "Directed graphs are not yet supported.",
         "edge_betweenness_centrality": "`weight` parameter is not yet supported, and RNG with seed may be different.",
+        "ego_graph": "Weighted ego_graph with negative cycles is not yet supported. `NotImplementedError` will be raised if there are negative `distance` edge weights.",
         "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.",
         "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.",
         "generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.",
@@ -191,6 +193,9 @@
         "bellman_ford_path_length": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
+        "ego_graph": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         "eigenvector_centrality": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
diff --git a/nx_cugraph/tests/test_ego_graph.py b/nx_cugraph/tests/test_ego_graph.py
new file mode 100644
index 000000000..5474f9d79
--- /dev/null
+++ b/nx_cugraph/tests/test_ego_graph.py
@@ -0,0 +1,81 @@
+# Copyright (c) 2024, 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.
+import networkx as nx
+import pytest
+from packaging.version import parse
+
+import nx_cugraph as nxcg
+
+from .testing_utils import assert_graphs_equal
+
+nxver = parse(nx.__version__)
+
+
+if nxver.major == 3 and nxver.minor < 2:
+    pytest.skip("Need NetworkX >=3.2 to test ego_graph", allow_module_level=True)
+
+
+@pytest.mark.parametrize(
+    "create_using", [nx.Graph, nx.DiGraph, nx.MultiGraph, nx.MultiDiGraph]
+)
+@pytest.mark.parametrize("radius", [-1, 0, 1, 1.5, 2, float("inf"), None])
+@pytest.mark.parametrize("center", [True, False])
+@pytest.mark.parametrize("undirected", [False, True])
+@pytest.mark.parametrize("multiple_edges", [False, True])
+@pytest.mark.parametrize("n", [0, 3])
+def test_ego_graph_cycle_graph(
+    create_using, radius, center, undirected, multiple_edges, n
+):
+    Gnx = nx.cycle_graph(7, create_using=create_using)
+    if multiple_edges:
+        # Test multigraph with multiple edges
+        if not Gnx.is_multigraph():
+            return
+        Gnx.add_edges_from(nx.cycle_graph(7, create_using=nx.DiGraph).edges)
+        Gnx.add_edge(0, 1, 10)
+    Gcg = nxcg.from_networkx(Gnx, preserve_all_attrs=True)
+    assert_graphs_equal(Gnx, Gcg)  # Sanity check
+
+    kwargs = {"radius": radius, "center": center, "undirected": undirected}
+    Hnx = nx.ego_graph(Gnx, n, **kwargs)
+    Hcg = nx.ego_graph(Gnx, n, **kwargs, backend="cugraph")
+    assert_graphs_equal(Hnx, Hcg)
+    with pytest.raises(nx.NodeNotFound, match="not in G"):
+        nx.ego_graph(Gnx, -1, **kwargs)
+    with pytest.raises(nx.NodeNotFound, match="not in G"):
+        nx.ego_graph(Gnx, -1, **kwargs, backend="cugraph")
+    # Using sssp with default weight of 1 should give same answer as bfs
+    nx.set_edge_attributes(Gnx, 1, name="weight")
+    Gcg = nxcg.from_networkx(Gnx, preserve_all_attrs=True)
+    assert_graphs_equal(Gnx, Gcg)  # Sanity check
+
+    kwargs["distance"] = "weight"
+    H2nx = nx.ego_graph(Gnx, n, **kwargs)
+    is_nx32 = nxver.major == 3 and nxver.minor == 2
+    if undirected and Gnx.is_directed() and Gnx.is_multigraph():
+        if is_nx32:
+            # `should_run` was added in nx 3.3
+            match = "Weighted ego_graph with undirected=True not implemented"
+        else:
+            match = "not implemented by cugraph"
+        with pytest.raises(RuntimeError, match=match):
+            nx.ego_graph(Gnx, n, **kwargs, backend="cugraph")
+        with pytest.raises(NotImplementedError, match="ego_graph"):
+            nx.ego_graph(Gcg, n, **kwargs)
+    else:
+        H2cg = nx.ego_graph(Gnx, n, **kwargs, backend="cugraph")
+        assert_graphs_equal(H2nx, H2cg)
+        with pytest.raises(nx.NodeNotFound, match="not found in graph"):
+            nx.ego_graph(Gnx, -1, **kwargs)
+        with pytest.raises(nx.NodeNotFound, match="not found in graph"):
+            nx.ego_graph(Gnx, -1, **kwargs, backend="cugraph")

From 32b23fb6f7addfb6668d7231990da9d9b57f8214 Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Tue, 30 Jul 2024 08:47:39 +0200
Subject: [PATCH 40/51] nx-cugraph: add `from_dict_of_lists` and
 `to_dict_of_lists` (#4537)

Tests were added to improve coverage. Perhaps we could/should upstream tests to networkx.

Authors:
  - Erik Welch (https://github.com/eriknw)
  - Ralph Liu (https://github.com/nv-rliu)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: https://github.com/rapidsai/cugraph/pull/4537
---
 README.md               | 3 +++
 _nx_cugraph/__init__.py | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/README.md b/README.md
index 27825585c..088f2fd20 100644
--- a/README.md
+++ b/README.md
@@ -253,6 +253,9 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
 classes
  └─ function
      └─ is_negatively_weighted
+convert
+ ├─ from_dict_of_lists
+ └─ to_dict_of_lists
 convert_matrix
  ├─ from_pandas_edgelist
  └─ from_scipy_sparse_array
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index f57b90eb4..3d27e4b9e 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -81,6 +81,7 @@
         "eigenvector_centrality",
         "empty_graph",
         "florentine_families_graph",
+        "from_dict_of_lists",
         "from_pandas_edgelist",
         "from_scipy_sparse_array",
         "frucht_graph",
@@ -138,6 +139,7 @@
         "star_graph",
         "tadpole_graph",
         "tetrahedral_graph",
+        "to_dict_of_lists",
         "transitivity",
         "triangles",
         "trivial_graph",

From 6e59ae9ee2c4954960f11d6ef78a620bd9db89ad Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Tue, 30 Jul 2024 08:53:35 +0200
Subject: [PATCH 41/51] nx-cugraph: add dijkstra sssp functions (#4538)

This does add new functionality (so it's not just sugar!), since dijstra methods have `cutoff=` arguments.

Note that we are missing multi-source dijstra methods, since `plc.sssp` only accepts a single source.

We also do not have `bidirectional_dijkstra`, since PLC does not implement this algorithm.

Authors:
  - Erik Welch (https://github.com/eriknw)
  - Rick Ratzel (https://github.com/rlratzel)
  - Ralph Liu (https://github.com/nv-rliu)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)

URL: https://github.com/rapidsai/cugraph/pull/4538
---
 README.md               | 10 +++++++++-
 _nx_cugraph/__init__.py | 36 ++++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 088f2fd20..8a1824a7a 100644
--- a/README.md
+++ b/README.md
@@ -173,11 +173,19 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
  └─ weighted
      ├─ all_pairs_bellman_ford_path
      ├─ all_pairs_bellman_ford_path_length
+     ├─ all_pairs_dijkstra
+     ├─ all_pairs_dijkstra_path
+     ├─ all_pairs_dijkstra_path_length
      ├─ bellman_ford_path
      ├─ bellman_ford_path_length
+     ├─ dijkstra_path
+     ├─ dijkstra_path_length
      ├─ single_source_bellman_ford
      ├─ single_source_bellman_ford_path
-     └─ single_source_bellman_ford_path_length
+     ├─ single_source_bellman_ford_path_length
+     ├─ single_source_dijkstra
+     ├─ single_source_dijkstra_path
+     └─ single_source_dijkstra_path_length
 traversal
  └─ breadth_first_search
      ├─ bfs_edges
diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py
index 3d27e4b9e..2d6017fa2 100644
--- a/_nx_cugraph/__init__.py
+++ b/_nx_cugraph/__init__.py
@@ -42,6 +42,9 @@
         # BEGIN: functions
         "all_pairs_bellman_ford_path",
         "all_pairs_bellman_ford_path_length",
+        "all_pairs_dijkstra",
+        "all_pairs_dijkstra_path",
+        "all_pairs_dijkstra_path_length",
         "all_pairs_shortest_path",
         "all_pairs_shortest_path_length",
         "ancestors",
@@ -75,6 +78,8 @@
         "descendants",
         "descendants_at_distance",
         "diamond_graph",
+        "dijkstra_path",
+        "dijkstra_path_length",
         "dodecahedral_graph",
         "edge_betweenness_centrality",
         "ego_graph",
@@ -132,6 +137,9 @@
         "single_source_bellman_ford",
         "single_source_bellman_ford_path",
         "single_source_bellman_ford_path_length",
+        "single_source_dijkstra",
+        "single_source_dijkstra_path",
+        "single_source_dijkstra_path_length",
         "single_source_shortest_path",
         "single_source_shortest_path_length",
         "single_target_shortest_path",
@@ -173,8 +181,8 @@
         "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.",
         "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.",
         "pagerank": "`dangling` parameter is not supported, but it is checked for validity.",
-        "shortest_path": "Negative weights are not yet supported, and method is ununsed.",
-        "shortest_path_length": "Negative weights are not yet supported, and method is ununsed.",
+        "shortest_path": "Negative weights are not yet supported.",
+        "shortest_path_length": "Negative weights are not yet supported.",
         "single_source_bellman_ford": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
         "single_source_bellman_ford_path": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
         "single_source_bellman_ford_path_length": "Negative cycles are not yet supported. ``NotImplementedError`` will be raised if there are negative edge weights. We plan to support negative edge weights soon. Also, callable ``weight`` argument is not supported.",
@@ -189,12 +197,27 @@
         "all_pairs_bellman_ford_path_length": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
+        "all_pairs_dijkstra": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "all_pairs_dijkstra_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "all_pairs_dijkstra_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         "bellman_ford_path": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
         "bellman_ford_path_length": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
+        "dijkstra_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "dijkstra_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         "ego_graph": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
@@ -229,6 +252,15 @@
         "single_source_bellman_ford_path_length": {
             "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
         },
+        "single_source_dijkstra": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "single_source_dijkstra_path": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
+        "single_source_dijkstra_path_length": {
+            "dtype : dtype or None, optional": "The data type (np.float32, np.float64, or None) to use for the edge weights in the algorithm. If None, then dtype is determined by the edge values.",
+        },
         # END: additional_parameters
     },
 }

From 64678412aae60b915f5aa596cb84f24eac403832 Mon Sep 17 00:00:00 2001
From: Erik Welch 
Date: Tue, 30 Jul 2024 20:42:58 +0200
Subject: [PATCH 42/51] nx-cugraph: add `relabel_nodes` and
 `convert_node_labels_to_integers` (#4531)

This was pretty tricky in places! This begins with `Graph` and `DiGraph`, which are probably tricker, because of the way edge data get merged when nodes are combined (and I wouldn't be surprised if there are other ways to do this operation).

This is one of the most heavily used functions in networkx and also networkx dependents.

Up next: multigraphs

Authors:
  - Erik Welch (https://github.com/eriknw)
  - Ralph Liu (https://github.com/nv-rliu)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)
  - Bradley Dice (https://github.com/bdice)

URL: https://github.com/rapidsai/cugraph/pull/4531
---
 README.md               | 3 +++
 _nx_cugraph/__init__.py | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/README.md b/README.md
index 8a1824a7a..458421e2b 100644
--- a/README.md
+++ b/README.md
@@ -267,6 +267,9 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
 convert_matrix
  ├─ from_pandas_edgelist
  └─ from_scipy_sparse_array
+relabel
+ ├─ convert_node_labels_to_integers
+ └─ relabel_nodes
 
To request nx-cugraph backend support for a NetworkX API that is not listed diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 2d6017fa2..d18fc53b8 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -69,6 +69,7 @@ "complete_graph", "complete_multipartite_graph", "connected_components", + "convert_node_labels_to_integers", "core_number", "cubical_graph", "cycle_graph", @@ -130,6 +131,7 @@ "path_graph", "petersen_graph", "reciprocity", + "relabel_nodes", "reverse", "sedgewick_maze_graph", "shortest_path", From 7659c206aea0bcabc416cbee0c2e5315571414e6 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 31 Jul 2024 17:33:18 +0200 Subject: [PATCH 43/51] nx-cugraph: check networkx version (#4571) This is to address the feedback from @bdice in https://github.com/rapidsai/cugraph/pull/4531#discussion_r1697414065, which I was unable to do in that PR. I know checking version strings is playing it fast-and-loose, but I believe we are abundantly safe to do so here, as networkx releases have been, and are expected to be, slow and predictable. Also, we do not have `packaging` as a runtime dependency (it _is_ a test dependency for finer control). So, even better than using `packaging.version.parse`, this PR performs a sanity check on the networkx version. I put it in both `nx_cugraph.__init__` and `_nx_cugraph.__init__` to give us obvious breadcrumbs to discover and follow. Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4571 --- _nx_cugraph/__init__.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index d18fc53b8..f58a6e229 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -296,6 +296,27 @@ def get_info(): return d +def _check_networkx_version(): + import warnings + + import networkx as nx + + version_major, version_minor = nx.__version__.split(".")[:2] + if version_major != "3": + warnings.warn( + f"nx-cugraph version {__version__} is only known to work with networkx " + f"versions 3.x, but networkx {nx.__version__} is installed. " + "Perhaps try upgrading your Python environment.", + UserWarning, + stacklevel=2, + ) + if len(version_minor) > 1: + raise RuntimeWarning( + f"nx-cugraph version {__version__} does not work with networkx version " + f"{nx.__version__}. Please upgrade (or fix) your Python environment." + ) + + if __name__ == "__main__": from pathlib import Path From dc0f90b97c2287cf73f26eeda5e9062d0800742c Mon Sep 17 00:00:00 2001 From: Ralph Liu <137829296+nv-rliu@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:06:27 -0400 Subject: [PATCH 44/51] Add Additional Check for `NetworkX` Release Candidate Versions (#4613) Part of https://github.com/rapidsai/graph_dl/issues/579 This PR allows `nx-cugraph` to operate with release candidate (under development) versions of `networkx` What This Pattern Allows: - Just a single digit: `3.4`, `3.9`, etc - Release Candidate format: `3.4rc0`. `3.7rc2` This is needed to complete adding nightly test coverage for development branches of `nx` Authors: - Ralph Liu (https://github.com/nv-rliu) Approvers: - Erik Welch (https://github.com/eriknw) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4613 --- _nx_cugraph/__init__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index f58a6e229..41c18c27e 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -298,6 +298,7 @@ def get_info(): def _check_networkx_version(): import warnings + import re import networkx as nx @@ -310,7 +311,11 @@ def _check_networkx_version(): UserWarning, stacklevel=2, ) - if len(version_minor) > 1: + + # Allow single-digit minor versions, e.g. 3.4 and release candidates, e.g. 3.4rc0 + pattern = r"^\d(rc\d+)?$" + + if not re.match(pattern, version_minor): raise RuntimeWarning( f"nx-cugraph version {__version__} does not work with networkx version " f"{nx.__version__}. Please upgrade (or fix) your Python environment." From da9c1a205c18eabb7fa74098489d20d9752ef0ea Mon Sep 17 00:00:00 2001 From: James Lamb Date: Mon, 26 Aug 2024 13:03:15 -0500 Subject: [PATCH 45/51] Drop Python 3.9 support (#4625) Contributes to https://github.com/rapidsai/build-planning/issues/88 Finishes the work of dropping Python 3.9 support. This project stopped building / testing against Python 3.9 as of https://github.com/rapidsai/shared-workflows/pull/235. This PR updates configuration and docs to reflect that. ## Notes for Reviewers ### How I tested this Checked that there were no remaining uses like this: ```shell git grep -E '3\.9' git grep '39' git grep 'py39' ``` And similar for variations on Python 3.8 (to catch things that were missed the last time this was done). Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Bradley Dice (https://github.com/bdice) - Brad Rees (https://github.com/BradReesWork) URL: https://github.com/rapidsai/cugraph/pull/4625 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 458421e2b..b18b99516 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ to run supported algorithms with GPU acceleration. nx-cugraph requires the following: * NVIDIA GPU, Volta architecture or later, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+ - * CUDA 11.2, 11.4, 11.5, 11.8, or 12.0 - * Python version 3.9, 3.10, or 3.11 + * CUDA 11.2, 11.4, 11.5, 11.8, 12.0, 12.2, or 12.5 + * Python version 3.10 or 3.11 * NetworkX >= version 3.0 (version 3.2 or higher recommended) More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req). From 49045605c3850bd37cf98228766d449998d0d08e Mon Sep 17 00:00:00 2001 From: James Lamb Date: Wed, 11 Sep 2024 11:28:24 -0500 Subject: [PATCH 46/51] Add support for Python 3.12 (#4647) Contributes to https://github.com/rapidsai/build-planning/issues/40 This PR adds support for Python 3.12. ## Notes for Reviewers This is part of ongoing work to add Python 3.12 support across RAPIDS. It temporarily introduces a build/test matrix including Python 3.12, from https://github.com/rapidsai/shared-workflows/pull/213. A follow-up PR will revert back to pointing at the `branch-24.10` branch of `shared-workflows` once all RAPIDS repos have added Python 3.12 support. ### This will fail until all dependencies have been updates to Python 3.12 CI here is expected to fail until all of this project's upstream dependencies support Python 3.12. This can be merged whenever all CI jobs are passing. Authors: - James Lamb (https://github.com/jameslamb) Approvers: - Bradley Dice (https://github.com/bdice) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4647 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b18b99516..c3ca0b880 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ to run supported algorithms with GPU acceleration. nx-cugraph requires the following: * NVIDIA GPU, Volta architecture or later, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+ * CUDA 11.2, 11.4, 11.5, 11.8, 12.0, 12.2, or 12.5 - * Python version 3.10 or 3.11 + * Python version 3.10, 3.11, or 3.12 * NetworkX >= version 3.0 (version 3.2 or higher recommended) More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req). From e73053782701e9eb1d17c398ada69a87f6663105 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 24 Sep 2024 17:20:07 -0500 Subject: [PATCH 47/51] nx-cugraph: Updates nxcg.Graph classes for API-compatibility with NetworkX Graph classes, needed for zero code change graph generators (#4629) This is an alternative approach to #4558 for enabling GPU-accelerated NetworkX to "just work". It has similarities to #4558. I opted to make separate classes such as `ZeroGraph`, which I think makes for cleaner separation and gives us and users more control. There are a few lingering TODOs and code comments to tidy up, but I don't think there are any show-stoppers. I have not updated methods (such as `number_of_nodes`) to optimistically try to use GPU if possible, b/c this is not strictly necessary, but we should update these soon. I have run NetworkX tests with these classes using https://github.com/networkx/networkx/pull/7585 and https://github.com/networkx/networkx/pull/7600. We need the behavior in 7585, and 7600 is only useful for testing. There are only 3 new failing tests, and 3 tests that hang (I'll run them overnight to see if they finish). Here's a test summary: ``` 5548 passed, 24 skipped, 16 xfailed, 25 xpassed ``` Note that 25 tests that were failing now pass. I have not investigated test failures, xfails, or xpasses yet. I would like to add tests too. We rely heavily on the networkx cache. I think this is preferred. It is late for me. I will describe and show how and why this works later. I opted for `zero=` and `ZeroGraph`, because I find them delightful! Renaming is trivial if other terms are preferred. CC @quasiben Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Bradley Dice (https://github.com/bdice) - Rick Ratzel (https://github.com/rlratzel) URL: https://github.com/rapidsai/cugraph/pull/4629 --- _nx_cugraph/__init__.py | 17 ++++++++++++-- nx_cugraph/tests/test_ego_graph.py | 36 ++++++++++++++++++++++-------- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 41c18c27e..428d266dd 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -22,6 +22,7 @@ $ python _nx_cugraph/__init__.py """ +import os from _nx_cugraph._version import __version__ @@ -293,12 +294,20 @@ def get_info(): for key in info_keys: del d[key] + + d["default_config"] = { + "use_compat_graphs": os.environ.get("NX_CUGRAPH_USE_COMPAT_GRAPHS", "true") + .strip() + .lower() + == "true", + } return d -def _check_networkx_version(): - import warnings +def _check_networkx_version() -> tuple[int, int]: + """Check the version of networkx and return ``(major, minor)`` version tuple.""" import re + import warnings import networkx as nx @@ -321,6 +330,10 @@ def _check_networkx_version(): f"{nx.__version__}. Please upgrade (or fix) your Python environment." ) + nxver_major = int(version_major) + nxver_minor = int(re.match(r"^\d+", version_minor).group()) + return (nxver_major, nxver_minor) + if __name__ == "__main__": from pathlib import Path diff --git a/nx_cugraph/tests/test_ego_graph.py b/nx_cugraph/tests/test_ego_graph.py index 5474f9d79..0697a744e 100644 --- a/nx_cugraph/tests/test_ego_graph.py +++ b/nx_cugraph/tests/test_ego_graph.py @@ -12,16 +12,13 @@ # limitations under the License. import networkx as nx import pytest -from packaging.version import parse import nx_cugraph as nxcg +from nx_cugraph import _nxver from .testing_utils import assert_graphs_equal -nxver = parse(nx.__version__) - - -if nxver.major == 3 and nxver.minor < 2: +if _nxver < (3, 2): pytest.skip("Need NetworkX >=3.2 to test ego_graph", allow_module_level=True) @@ -49,7 +46,12 @@ def test_ego_graph_cycle_graph( kwargs = {"radius": radius, "center": center, "undirected": undirected} Hnx = nx.ego_graph(Gnx, n, **kwargs) Hcg = nx.ego_graph(Gnx, n, **kwargs, backend="cugraph") + use_compat_graphs = _nxver < (3, 3) or nx.config.backends.cugraph.use_compat_graphs + assert_graphs_equal(Hnx, Hcg._cudagraph if use_compat_graphs else Hcg) + Hcg = nx.ego_graph(Gcg, n, **kwargs) assert_graphs_equal(Hnx, Hcg) + Hcg = nx.ego_graph(Gcg._to_compat_graph(), n, **kwargs) + assert_graphs_equal(Hnx, Hcg._cudagraph) with pytest.raises(nx.NodeNotFound, match="not in G"): nx.ego_graph(Gnx, -1, **kwargs) with pytest.raises(nx.NodeNotFound, match="not in G"): @@ -61,20 +63,36 @@ def test_ego_graph_cycle_graph( kwargs["distance"] = "weight" H2nx = nx.ego_graph(Gnx, n, **kwargs) - is_nx32 = nxver.major == 3 and nxver.minor == 2 + is_nx32 = _nxver[:2] == (3, 2) if undirected and Gnx.is_directed() and Gnx.is_multigraph(): if is_nx32: # `should_run` was added in nx 3.3 match = "Weighted ego_graph with undirected=True not implemented" + elif _nxver >= (3, 4): + match = "not implemented by 'cugraph'" else: match = "not implemented by cugraph" - with pytest.raises(RuntimeError, match=match): + with pytest.raises( + RuntimeError if _nxver < (3, 4) else NotImplementedError, match=match + ): nx.ego_graph(Gnx, n, **kwargs, backend="cugraph") with pytest.raises(NotImplementedError, match="ego_graph"): - nx.ego_graph(Gcg, n, **kwargs) + nx.ego_graph(Gcg, n, **kwargs, backend="cugraph") + if _nxver < (3, 4): + with pytest.raises(NotImplementedError, match="ego_graph"): + nx.ego_graph(Gcg, n, **kwargs) + else: + # This is an interesting case. `nxcg.ego_graph` is not implemented for + # these arguments, so it falls back to networkx. Hence, as it is currently + # implemented, the input graph is `nxcg.CudaGraph`, but the output graph + # is `nx.Graph`. Should networkx convert back to "cugraph" backend? + # TODO: make fallback to networkx configurable. + H2cg = nx.ego_graph(Gcg, n, **kwargs) + assert type(H2nx) is type(H2cg) + assert_graphs_equal(H2nx, nxcg.from_networkx(H2cg, preserve_all_attrs=True)) else: H2cg = nx.ego_graph(Gnx, n, **kwargs, backend="cugraph") - assert_graphs_equal(H2nx, H2cg) + assert_graphs_equal(H2nx, H2cg._cudagraph if use_compat_graphs else H2cg) with pytest.raises(nx.NodeNotFound, match="not found in graph"): nx.ego_graph(Gnx, -1, **kwargs) with pytest.raises(nx.NodeNotFound, match="not found in graph"): From dea898b23e6448e8b8ff320ceeb162e5d0204951 Mon Sep 17 00:00:00 2001 From: Ralph Liu <137829296+nv-rliu@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:51:33 -0400 Subject: [PATCH 48/51] Add `nx-cugraph` Docs Pages (#4669) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes https://github.com/rapidsai/graph_dl/issues/606 and [another issue] ## Proposed Changes In preparation for GA release, this PR adds a landing page for `nx-cugraph` in the cugraph API documentation site. The new pages can be viewed by clicking `nx-cugraph` in the navigation bar at the top of the page. ### New pages nx-cugraph └─ How it works └─ Supported Algorithms └─ Getting Started └─ Benchmarks └─ FAQ ## Notes for Reviewers - In order to build and test these docs, I modified the `build.sh` file to use `sphinx-autobuild`. ```bash 122 123 cd ${REPODIR}/docs/cugraph-docs 124 #make html 125 sphinx-autobuild source build/html 126 fi 127 ``` - For now, I believe the best way to view these changes is to clone the PR branch, then run `build.sh` in order to host the webserver locally.. --------- Co-authored-by: Don Acosta <97529984+acostadon@users.noreply.github.com> Co-authored-by: rlratzel Co-authored-by: Erik Welch --- _nx_cugraph/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index 428d266dd..a5e45979f 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -36,7 +36,7 @@ "backend_name": "cugraph", "project": "nx-cugraph", "package": "nx_cugraph", - "url": f"https://github.com/rapidsai/cugraph/tree/branch-{_version_major:0>2}.{_version_minor:0>2}/python/nx-cugraph", + "url": f"https://rapids.ai/nx-cugraph", "short_summary": "GPU-accelerated backend.", # "description": "TODO", "functions": { From cfb0b9335acb985fef81ccaab1dc2c01d0fa147e Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Mon, 7 Oct 2024 09:53:07 -0500 Subject: [PATCH 49/51] `nx-cugraph`: add `NX_CUGRAPH_AUTOCONFIG=True` env var to enable full zero-code change (#4685) This is for convenience and sets or updates `NETWORKX` environment variables. Do we like `NX_CUGRAPH` as the env var name? What should we consider a true value: "True" (case-insensitive) or a non-empty value? This works with the latest dev version of NetworkX. I have not yet tried it with older NetworkX versions. Authors: - Erik Welch (https://github.com/eriknw) - https://github.com/jakirkham Approvers: - Rick Ratzel (https://github.com/rlratzel) - Ralph Liu (https://github.com/nv-rliu) URL: https://github.com/rapidsai/cugraph/pull/4685 --- _nx_cugraph/__init__.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index a5e45979f..fc0bea471 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -301,6 +301,45 @@ def get_info(): .lower() == "true", } + + # Enable zero-code change usage with a simple environment variable + # by setting or updating other NETWORKX environment variables. + if os.environ.get("NX_CUGRAPH_AUTOCONFIG", "").strip().lower() == "true": + from itertools import chain + + def update_env_var(varname): + """Add "cugraph" to a list of backend names environment variable.""" + if varname not in os.environ: + os.environ[varname] = "cugraph" + return + string = os.environ[varname] + vals = [ + stripped for x in string.strip().split(",") if (stripped := x.strip()) + ] + if "cugraph" not in vals: + # Should we append or prepend? Let's be first! + os.environ[varname] = ",".join(chain(["cugraph"], vals)) + + # Automatically convert NetworkX Graphs to nx-cugraph for algorithms + if (varname := "NETWORKX_BACKEND_PRIORITY_ALGOS") in os.environ: + # "*_ALGOS" is given priority in NetworkX >=3.4 + update_env_var(varname) + # But update this too to "just work" if users mix env vars and nx versions + os.environ["NETWORKX_BACKEND_PRIORITY"] = os.environ[varname] + else: + update_env_var("NETWORKX_BACKEND_PRIORITY") + # And for older NetworkX versions + update_env_var("NETWORKX_AUTOMATIC_BACKENDS") # For NetworkX 3.2 + update_env_var("NETWORKX_GRAPH_CONVERT") # For NetworkX 3.0 and 3.1 + # Automatically create nx-cugraph Graph from graph generators + update_env_var("NETWORKX_BACKEND_PRIORITY_GENERATORS") + # Run default NetworkX implementation (in >=3.4) if not implemented by nx-cugraph + if (varname := "NETWORKX_FALLBACK_TO_NX") not in os.environ: + os.environ[varname] = "true" + # Cache graph conversions (default is False in NetworkX 3.2 + if (varname := "NETWORKX_CACHE_CONVERTED_GRAPHS") not in os.environ: + os.environ[varname] = "true" + return d From 06f7aecec243dc25c1c96e88806504e0014e7c7c Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Tue, 15 Oct 2024 05:55:05 -0500 Subject: [PATCH 50/51] Update nx-cugraph to NetworkX 3.4 (#4717) This run `make` in `python/nx-cugraph` directory and update the pre-commit hook. Also fixes `ego_graph` tests to check `nx.config.fallback_to_nx` configuration. Authors: - Erik Welch (https://github.com/eriknw) Approvers: - Rick Ratzel (https://github.com/rlratzel) - Jake Awe (https://github.com/AyodeAwe) URL: https://github.com/rapidsai/cugraph/pull/4717 --- _nx_cugraph/__init__.py | 4 ++-- nx_cugraph/tests/test_ego_graph.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/_nx_cugraph/__init__.py b/_nx_cugraph/__init__.py index fc0bea471..9feeda568 100644 --- a/_nx_cugraph/__init__.py +++ b/_nx_cugraph/__init__.py @@ -36,7 +36,7 @@ "backend_name": "cugraph", "project": "nx-cugraph", "package": "nx_cugraph", - "url": f"https://rapids.ai/nx-cugraph", + "url": "https://rapids.ai/nx-cugraph", "short_summary": "GPU-accelerated backend.", # "description": "TODO", "functions": { @@ -180,7 +180,7 @@ "ego_graph": "Weighted ego_graph with negative cycles is not yet supported. `NotImplementedError` will be raised if there are negative `distance` edge weights.", "eigenvector_centrality": "`nstart` parameter is not used, but it is checked for validity.", "from_pandas_edgelist": "cudf.DataFrame inputs also supported; value columns with str is unsuppported.", - "generic_bfs_edges": "`neighbors` and `sort_neighbors` parameters are not yet supported.", + "generic_bfs_edges": "`neighbors` parameter is not yet supported.", "katz_centrality": "`nstart` isn't used (but is checked), and `normalized=False` is not supported.", "louvain_communities": "`seed` parameter is currently ignored, and self-loops are not yet supported.", "pagerank": "`dangling` parameter is not supported, but it is checked for validity.", diff --git a/nx_cugraph/tests/test_ego_graph.py b/nx_cugraph/tests/test_ego_graph.py index 0697a744e..f3d0a8d37 100644 --- a/nx_cugraph/tests/test_ego_graph.py +++ b/nx_cugraph/tests/test_ego_graph.py @@ -78,7 +78,7 @@ def test_ego_graph_cycle_graph( nx.ego_graph(Gnx, n, **kwargs, backend="cugraph") with pytest.raises(NotImplementedError, match="ego_graph"): nx.ego_graph(Gcg, n, **kwargs, backend="cugraph") - if _nxver < (3, 4): + if _nxver < (3, 4) or not nx.config.fallback_to_nx: with pytest.raises(NotImplementedError, match="ego_graph"): nx.ego_graph(Gcg, n, **kwargs) else: @@ -86,7 +86,6 @@ def test_ego_graph_cycle_graph( # these arguments, so it falls back to networkx. Hence, as it is currently # implemented, the input graph is `nxcg.CudaGraph`, but the output graph # is `nx.Graph`. Should networkx convert back to "cugraph" backend? - # TODO: make fallback to networkx configurable. H2cg = nx.ego_graph(Gcg, n, **kwargs) assert type(H2nx) is type(H2cg) assert_graphs_equal(H2nx, nxcg.from_networkx(H2cg, preserve_all_attrs=True)) From 58757db6224be8b781d14277d7d0cdbde5fbaad2 Mon Sep 17 00:00:00 2001 From: Ralph Liu <137829296+nv-rliu@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:51:46 -0400 Subject: [PATCH 51/51] Update `nx-cugraph` README with New Env Variable (#4705) This PR updates the nx-cugraph README with the new `NX_CUGRAPH_AUTOCONFIG` variable. --------- Co-authored-by: Rick Ratzel <3039903+rlratzel@users.noreply.github.com> --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c3ca0b880..8cc3a5d90 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # nx-cugraph ## Description -[RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/reference/utils.html#backends) +[RAPIDS](https://rapids.ai) nx-cugraph is a [backend to NetworkX](https://networkx.org/documentation/stable/backends.html) to run supported algorithms with GPU acceleration. ## System Requirements @@ -10,7 +10,7 @@ nx-cugraph requires the following: * NVIDIA GPU, Volta architecture or later, with [compute capability](https://developer.nvidia.com/cuda-gpus) 7.0+ * CUDA 11.2, 11.4, 11.5, 11.8, 12.0, 12.2, or 12.5 * Python version 3.10, 3.11, or 3.12 - * NetworkX >= version 3.0 (version 3.2 or higher recommended) + * NetworkX >= version 3.0 (version 3.4 or higher recommended) More details about system requirements can be found in the [RAPIDS System Requirements documentation](https://docs.rapids.ai/install#system-req). @@ -45,18 +45,20 @@ Notes: NetworkX will use nx-cugraph as the graph analytics backend if any of the following are used: -### `NETWORKX_AUTOMATIC_BACKENDS` environment variable. -The `NETWORKX_AUTOMATIC_BACKENDS` environment variable can be used to have NetworkX automatically dispatch to specified backends an API is called that the backend supports. -Set `NETWORKX_AUTOMATIC_BACKENDS=cugraph` to use nx-cugraph to GPU accelerate supported APIs with no code changes. +### `NX_CUGRAPH_AUTOCONFIG` environment variable. +By setting `NX_CUGRAPH_AUTOCONFIG=True`, NetworkX will automatically dispatch algorithm calls to nx-cugraph (if the backend is supported). This allows users to GPU accelerate their code with zero code change. + +Read more on [Networkx Backends and How They Work](https://networkx.org/documentation/stable/reference/backends.html). + Example: ``` -bash> NETWORKX_AUTOMATIC_BACKENDS=cugraph python my_networkx_script.py +bash> NX_CUGRAPH_AUTOCONFIG=True python my_networkx_script.py ``` ### `backend=` keyword argument To explicitly specify a particular backend for an API, use the `backend=` keyword argument. This argument takes precedence over the -`NETWORKX_AUTOMATIC_BACKENDS` environment variable. This requires anyone +`NX_CUGRAPH_AUTOCONFIG` environment variable. This requires anyone running code that uses the `backend=` keyword argument to have the specified backend installed.