Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fast-forwarded files from cugraph into nx-cugraph #13

Merged
merged 66 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
1f589ed
Rename `cugraph-nx` to `nx-cugraph` (#3840)
eriknw Sep 6, 2023
429797d
v23.12 Updates [skip ci]
raydouglass Sep 22, 2023
ef159d7
Add entry point to tell NetworkX about nx-cugraph without importing i…
eriknw Sep 28, 2023
c543959
Merge branch-23.10 into branch-23.12
rlratzel Sep 28, 2023
aedb066
Merge pull request #3898 from rlratzel/branch-23.12-merge-23.10
raydouglass Sep 28, 2023
69e1a02
nx-cugraph: handle louvain with isolated nodes (#3897)
eriknw Oct 3, 2023
fd7f955
Adds benchmarks for `nx-cugraph` (#3854)
rlratzel Oct 6, 2023
f9e628e
Merge branch-23.08 into branch-23.10
nv-rliu Oct 6, 2023
377c9c5
Merge pull request #3919 from nv-rliu/branch-23.12-merge-23.10
raydouglass Oct 14, 2023
73c5058
Updates to 23.12 (#3905)
raydouglass Oct 17, 2023
b53448e
nx-cugraph: add k_truss and degree centralities (#3945)
eriknw Oct 25, 2023
dd4ab33
Add many graph generators to nx-cugraph (#3954)
eriknw Oct 31, 2023
e8e42f1
nx-cugraph: add CC for undirected graphs to fix k-truss (#3965)
eriknw Oct 31, 2023
c06ef82
Updates README file to include nx-cugraph user documentation, adds nx…
rlratzel Nov 8, 2023
acbece7
Fixes typos, updates link to NX backend docs. (#3989)
rlratzel Nov 8, 2023
ad019ef
Adds update-version.sh support for proper versioning to cu version su…
rlratzel Nov 14, 2023
095f6f3
v24.02 Updates [skip ci]
raydouglass Nov 14, 2023
9f8bdb2
nx-cugraph: add SSSP (unweighted) (#3976)
eriknw Nov 20, 2023
2d3d7ed
Merge pull request #4016 from rapidsai/branch-23.12
GPUtester Nov 20, 2023
0b1db0f
nx-cugraph: add `eigenvector_centrality`, `katz_centrality`, `hits`, …
eriknw Nov 22, 2023
c582d07
Adds missing connected_components algo to table. (#4019)
rlratzel Nov 22, 2023
f72e9d5
Merge branch-23.12 into branch-24.02
rlratzel Nov 26, 2023
97ef157
Merge pull request #4020 from rlratzel/branch-24.02-merge-23.12
AyodeAwe Nov 27, 2023
4545e3f
nx-cugraph: add `ancestors` and `descendants` (#4029)
eriknw Dec 21, 2023
b453e00
nx-cugraph: PLC now handles isolated nodes; clean up our workarounds …
eriknw Jan 16, 2024
ee044a8
nx-cugraph: add weakly connected components (#4071)
eriknw Jan 17, 2024
a606ee3
`nx-cugraph`: add `to_undirected` method; add reciprocity algorithms …
eriknw Jan 18, 2024
1bca3c9
DOC v24.04 Updates [skip ci]
raydouglass Jan 18, 2024
129b6de
nx-cugraph: add triangles and clustering algorithms (#4093)
eriknw Jan 19, 2024
8f37e22
Merge pull request #4101 from rapidsai/branch-24.02
GPUtester Jan 19, 2024
c991da0
nx-cugraph: add `core_number` (undirected graphs only) (#4100)
eriknw Jan 19, 2024
017cc1b
Merge pull request #4102 from rapidsai/branch-24.02
GPUtester Jan 19, 2024
e9000cb
nx-cugraph: add `is_tree`, etc. (#4097)
eriknw Jan 22, 2024
50ad1e5
Merge pull request #4105 from rapidsai/branch-24.02
GPUtester Jan 22, 2024
f0077c1
nx-cugraph: add `complement` and `reverse` (#4103)
eriknw Jan 25, 2024
83f6b2e
Merge pull request #4117 from rapidsai/branch-24.02
GPUtester Jan 25, 2024
85969f0
Removes the `networkx_algorithm` decorator to all SCC functions to di…
rlratzel Feb 2, 2024
b987276
Merge pull request #4138 from rapidsai/branch-24.02
GPUtester Feb 2, 2024
194e416
Updates nx-cugraph README.md with latest algos (#4135)
rlratzel Feb 2, 2024
c2c3523
Merge pull request #4140 from rapidsai/branch-24.02
GPUtester Feb 2, 2024
6f81e6a
Update `louvain_communities` to match NetworkX 3.3 (added max_level) …
eriknw Feb 26, 2024
1d6db08
nx-cugraph: update `get_info` function keys to NetworkX 3.3 (#4192)
eriknw Feb 26, 2024
77674e6
nx-cugraph: automatically generate trees in README.md (#4156)
eriknw Feb 27, 2024
2770023
Fix `louvain_communities`, `PropertyGraph`, cudf `column.full`, dgl 2…
eriknw Mar 7, 2024
cf5a822
nx-cugraph: add more shortest path algorithms (#4199)
eriknw Mar 13, 2024
50e132f
Remove hard-coding of RAPIDS version where possible (#4217)
KyleFromNVIDIA Mar 13, 2024
08b08c3
Updates nx-cugraph `README` for latest h/w, CUDA, python, NX requirem…
rlratzel Mar 13, 2024
3765dbf
Removes (unintentional?) runtime dependency on `packaging` from nx-cu…
rlratzel Mar 15, 2024
932d499
nx-cugraph: add `is_negatively_weighted` (#4242)
eriknw Mar 15, 2024
99415a1
Updates the nx-cugraph README.md with the latest upstream URLs (#4321)
rlratzel Apr 9, 2024
c60782a
Update `k_truss` to work with many connected components (#4383)
eriknw May 2, 2024
9c4ec60
nx-cugraph: add `ego_graph` (#4395)
eriknw May 21, 2024
b35f8fe
Merge pull request #4454 from nv-rliu/branch-24.08-merge-24.06
AyodeAwe Jun 4, 2024
32b23fb
nx-cugraph: add `from_dict_of_lists` and `to_dict_of_lists` (#4537)
eriknw Jul 30, 2024
6e59ae9
nx-cugraph: add dijkstra sssp functions (#4538)
eriknw Jul 30, 2024
6467841
nx-cugraph: add `relabel_nodes` and `convert_node_labels_to_integers`…
eriknw Jul 30, 2024
7659c20
nx-cugraph: check networkx version (#4571)
eriknw Jul 31, 2024
dc0f90b
Add Additional Check for `NetworkX` Release Candidate Versions (#4613)
nv-rliu Aug 16, 2024
da9c1a2
Drop Python 3.9 support (#4625)
jameslamb Aug 26, 2024
4904560
Add support for Python 3.12 (#4647)
jameslamb Sep 11, 2024
e730537
nx-cugraph: Updates nxcg.Graph classes for API-compatibility with Net…
eriknw Sep 24, 2024
dea898b
Add `nx-cugraph` Docs Pages (#4669)
nv-rliu Oct 3, 2024
cfb0b93
`nx-cugraph`: add `NX_CUGRAPH_AUTOCONFIG=True` env var to enable full…
eriknw Oct 7, 2024
06f7aec
Update nx-cugraph to NetworkX 3.4 (#4717)
eriknw Oct 15, 2024
58757db
Update `nx-cugraph` README with New Env Variable (#4705)
nv-rliu Oct 15, 2024
8b8a767
Merge remote-tracking branch 'filtered-repo/branch-24.12' into merge-…
nv-rliu Nov 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.4-11.8 or 12.0-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).

Expand Down Expand Up @@ -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.

Expand Down
39 changes: 39 additions & 0 deletions _nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 1 addition & 2 deletions nx_cugraph/tests/test_ego_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ 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:
# 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))
Expand Down
Loading