-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'branch-25.02' into b25.02-bench-algo-updates
- Loading branch information
Showing
9 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# nx-cugraph 24.12.00 (11 Dec 2024) | ||
|
||
## 🚨 Breaking Changes | ||
|
||
- Add `nx-cugraph` Package Publishing ([#16](https://github.com/rapidsai/nx-cugraph/pull/16)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Merge fast-forwarded files from cugraph into nx-cugraph ([#13](https://github.com/rapidsai/nx-cugraph/pull/13)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Update `.pre-commit-config.yaml` and Implement Suggestions ([#12](https://github.com/rapidsai/nx-cugraph/pull/12)) [@nv-rliu](https://github.com/nv-rliu) | ||
- [CI] Adding CI Workflows: checks, changed-files, builds ([#6](https://github.com/rapidsai/nx-cugraph/pull/6)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Setting Up New Repo, Adding Files, etc. ([#5](https://github.com/rapidsai/nx-cugraph/pull/5)) [@nv-rliu](https://github.com/nv-rliu) | ||
|
||
## 🐛 Bug Fixes | ||
|
||
- Add sphinx-lint pre-commit (and some docs fixes) ([#29](https://github.com/rapidsai/nx-cugraph/pull/29)) [@eriknw](https://github.com/eriknw) | ||
- Update and test `_nx_cugraph._check_networkx_version` ([#24](https://github.com/rapidsai/nx-cugraph/pull/24)) [@eriknw](https://github.com/eriknw) | ||
- Remove automatic "Python" labeler ([#23](https://github.com/rapidsai/nx-cugraph/pull/23)) [@eriknw](https://github.com/eriknw) | ||
|
||
## 📖 Documentation | ||
|
||
- Remove `docs/` directory ([#37](https://github.com/rapidsai/nx-cugraph/pull/37)) [@eriknw](https://github.com/eriknw) | ||
|
||
## 🛠️ Improvements | ||
|
||
- Small Updates to Benchmarks Directory ([#48](https://github.com/rapidsai/nx-cugraph/pull/48)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Includes all deferred conversion costs in benchmarks ([#34](https://github.com/rapidsai/nx-cugraph/pull/34)) [@rlratzel](https://github.com/rlratzel) | ||
- Add Bipartite Betweenness Centrality ([#32](https://github.com/rapidsai/nx-cugraph/pull/32)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Change `degree_type` of `core_number` to `"outgoing"` ([#28](https://github.com/rapidsai/nx-cugraph/pull/28)) [@eriknw](https://github.com/eriknw) | ||
- Drop support for NetworkX 3.0 and 3.1 ([#27](https://github.com/rapidsai/nx-cugraph/pull/27)) [@eriknw](https://github.com/eriknw) | ||
- remove versioning workaround for nightlies ([#26](https://github.com/rapidsai/nx-cugraph/pull/26)) [@jameslamb](https://github.com/jameslamb) | ||
- add devcontainers ([#25](https://github.com/rapidsai/nx-cugraph/pull/25)) [@jameslamb](https://github.com/jameslamb) | ||
- Add pre-commit hook to disallow improper comparison to `_nxver` ([#22](https://github.com/rapidsai/nx-cugraph/pull/22)) [@eriknw](https://github.com/eriknw) | ||
- Add notebooks/demo/accelerating_networkx.ipynb ([#21](https://github.com/rapidsai/nx-cugraph/pull/21)) [@eriknw](https://github.com/eriknw) | ||
- enforce wheel size limits, README formatting in CI ([#19](https://github.com/rapidsai/nx-cugraph/pull/19)) [@jameslamb](https://github.com/jameslamb) | ||
- Faster `shortest_path` ([#18](https://github.com/rapidsai/nx-cugraph/pull/18)) [@eriknw](https://github.com/eriknw) | ||
- nx-cugraph: dispatch graph method to gpu or cpu ([#17](https://github.com/rapidsai/nx-cugraph/pull/17)) [@eriknw](https://github.com/eriknw) | ||
- Add `nx-cugraph` Package Publishing ([#16](https://github.com/rapidsai/nx-cugraph/pull/16)) [@nv-rliu](https://github.com/nv-rliu) | ||
- add CI workflows running tests ([#15](https://github.com/rapidsai/nx-cugraph/pull/15)) [@jameslamb](https://github.com/jameslamb) | ||
- remove more cugraph-only details, other miscellaneous build/packaging changes ([#14](https://github.com/rapidsai/nx-cugraph/pull/14)) [@jameslamb](https://github.com/jameslamb) | ||
- Merge fast-forwarded files from cugraph into nx-cugraph ([#13](https://github.com/rapidsai/nx-cugraph/pull/13)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Update `.pre-commit-config.yaml` and Implement Suggestions ([#12](https://github.com/rapidsai/nx-cugraph/pull/12)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Adding a `dependencies.yaml` file ([#9](https://github.com/rapidsai/nx-cugraph/pull/9)) [@nv-rliu](https://github.com/nv-rliu) | ||
- [CI] Adding CI Workflows: checks, changed-files, builds ([#6](https://github.com/rapidsai/nx-cugraph/pull/6)) [@nv-rliu](https://github.com/nv-rliu) | ||
- Setting Up New Repo, Adding Files, etc. ([#5](https://github.com/rapidsai/nx-cugraph/pull/5)) [@nv-rliu](https://github.com/nv-rliu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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 cupy as cp | ||
import pylibcugraph as plc | ||
|
||
from nx_cugraph.convert import _to_graph | ||
from nx_cugraph.utils import networkx_algorithm | ||
|
||
__all__ = ["betweenness_centrality"] | ||
|
||
|
||
@networkx_algorithm( | ||
name="bipartite_betweenness_centrality", | ||
version_added="24.12", | ||
_plc="betweenness_centrality", | ||
) | ||
def betweenness_centrality(G, nodes): | ||
G = _to_graph(G) | ||
|
||
node_ids, values = plc.betweenness_centrality( | ||
resource_handle=plc.ResourceHandle(), | ||
graph=G._get_plc_graph(), | ||
k=None, | ||
random_state=None, | ||
normalized=False, | ||
include_endpoints=False, | ||
do_expensive_check=False, | ||
) | ||
top_node_ids = G._nodekeys_to_nodearray(set(nodes)) | ||
bottom_node_ids = cp.delete(cp.arange(G._N, dtype=top_node_ids.dtype), top_node_ids) | ||
n = top_node_ids.size | ||
m = bottom_node_ids.size | ||
s, t = divmod(n - 1, m) | ||
bet_max_top = ( | ||
((m**2) * ((s + 1) ** 2)) | ||
+ (m * (s + 1) * (2 * t - s - 1)) | ||
- (t * ((2 * s) - t + 3)) | ||
) / 2.0 | ||
p, r = divmod(m - 1, n) | ||
bet_max_bot = ( | ||
((n**2) * ((p + 1) ** 2)) | ||
+ (n * (p + 1) * (2 * r - p - 1)) | ||
- (r * ((2 * p) - r + 3)) | ||
) / 2.0 | ||
|
||
values = values[cp.argsort(node_ids)] | ||
|
||
values[top_node_ids] /= bet_max_top | ||
values[bottom_node_ids] /= bet_max_bot | ||
|
||
return G._nodearray_to_dict(values) |