Skip to content

Commit c7d4228

Browse files
Update nx-cugraph metadata, README generation, from_biadjacency_matrix for networkx 3.6.1 compat (#218)
networkx/networkx#8286, introduced in networkx 3.6, changed the documentation URLs. networkx/networkx#8373, introduced in networkx 3.6.1, reverted this change. Require networkx 3.6.1 to get the reversion. Authors: - Kyle Edwards (https://github.com/KyleFromNVIDIA) - Rick Ratzel (https://github.com/rlratzel) Approvers: - Gil Forsyth (https://github.com/gforsyth) - Bradley Dice (https://github.com/bdice) - Rick Ratzel (https://github.com/rlratzel) URL: #218
1 parent eda5677 commit c7d4228

File tree

5 files changed

+121
-41
lines changed

5 files changed

+121
-41
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ repos:
9999
types: [python]
100100
language: python
101101
pass_filenames: false
102-
additional_dependencies: ["networkx>=3.6"]
102+
additional_dependencies: ["networkx>=3.6.1"]
103103
- repo: local
104104
hooks:
105105
- id: nx-cugraph-readme-update
@@ -109,7 +109,7 @@ repos:
109109
types_or: [python, markdown]
110110
language: python
111111
pass_filenames: false
112-
additional_dependencies: ["networkx>=3.6"]
112+
additional_dependencies: ["networkx>=3.6.1"]
113113
- repo: local
114114
hooks:
115115
- id: disallow-improper-nxver-comparison
@@ -122,7 +122,7 @@ repos:
122122
# Use e.g. `_nxver < ...` or `_nxver >= ...` instead
123123
exclude: .pre-commit-config.yaml
124124
- repo: https://github.com/rapidsai/pre-commit-hooks
125-
rev: v1.2.0
125+
rev: v1.2.1
126126
hooks:
127127
- id: verify-copyright
128128
args: [--fix, --spdx]

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -219,35 +219,35 @@ Below is the list of algorithms that are currently supported in nx-cugraph.
219219
<a href="https://networkx.org/documentation/stable/reference/algorithms/reciprocity.html#module-networkx.algorithms.reciprocity">reciprocity</a>
220220
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.reciprocity.overall_reciprocity.html#networkx.algorithms.reciprocity.overall_reciprocity">overall_reciprocity</a>
221221
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.reciprocity.reciprocity.html#networkx.algorithms.reciprocity.reciprocity">reciprocity</a>
222-
<a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/index.html">shortest_paths</a>
223-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/index.html#module-networkx.algorithms.shortest_paths.generic">generic</a>
224-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.generic.has_path.html#networkx.algorithms.shortest_paths.generic.has_path">has_path</a>
225-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html#networkx.algorithms.shortest_paths.generic.shortest_path">shortest_path</a>
226-
│ └─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.generic.shortest_path_length.html#networkx.algorithms.shortest_paths.generic.shortest_path_length">shortest_path_length</a>
227-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/index.html#module-networkx.algorithms.shortest_paths.unweighted">unweighted</a>
228-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path">all_pairs_shortest_path</a>
229-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path_length">all_pairs_shortest_path_length</a>
230-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path">bidirectional_shortest_path</a>
231-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path">single_source_shortest_path</a>
232-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path_length">single_source_shortest_path_length</a>
233-
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path">single_target_shortest_path</a>
234-
│ └─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path_length">single_target_shortest_path_length</a>
235-
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/index.html#module-networkx.algorithms.shortest_paths.weighted">weighted</a>
236-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path">all_pairs_bellman_ford_path</a>
237-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path_length">all_pairs_bellman_ford_path_length</a>
238-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra">all_pairs_dijkstra</a>
239-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path">all_pairs_dijkstra_path</a>
240-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path_length">all_pairs_dijkstra_path_length</a>
241-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.bellman_ford_path">bellman_ford_path</a>
242-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.bellman_ford_path_length">bellman_ford_path_length</a>
243-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.dijkstra_path">dijkstra_path</a>
244-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.dijkstra_path_length">dijkstra_path_length</a>
245-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford">single_source_bellman_ford</a>
246-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path">single_source_bellman_ford_path</a>
247-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path_length">single_source_bellman_ford_path_length</a>
248-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra">single_source_dijkstra</a>
249-
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path">single_source_dijkstra_path</a>
250-
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path_length">single_source_dijkstra_path_length</a>
222+
<a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html">shortest_paths</a>
223+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html#module-networkx.algorithms.shortest_paths.generic">generic</a>
224+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.generic.has_path.html#networkx.algorithms.shortest_paths.generic.has_path">has_path</a>
225+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html#networkx.algorithms.shortest_paths.generic.shortest_path">shortest_path</a>
226+
│ └─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.generic.shortest_path_length.html#networkx.algorithms.shortest_paths.generic.shortest_path_length">shortest_path_length</a>
227+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html#module-networkx.algorithms.shortest_paths.unweighted">unweighted</a>
228+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path">all_pairs_shortest_path</a>
229+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.all_pairs_shortest_path_length">all_pairs_shortest_path_length</a>
230+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.bidirectional_shortest_path">bidirectional_shortest_path</a>
231+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path">single_source_shortest_path</a>
232+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.single_source_shortest_path_length">single_source_shortest_path_length</a>
233+
│ ├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path.html#networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path">single_target_shortest_path</a>
234+
│ └─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path_length.html#networkx.algorithms.shortest_paths.unweighted.single_target_shortest_path_length">single_target_shortest_path_length</a>
235+
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html#module-networkx.algorithms.shortest_paths.weighted">weighted</a>
236+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path">all_pairs_bellman_ford_path</a>
237+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.all_pairs_bellman_ford_path_length">all_pairs_bellman_ford_path_length</a>
238+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra">all_pairs_dijkstra</a>
239+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path">all_pairs_dijkstra_path</a>
240+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path_length">all_pairs_dijkstra_path_length</a>
241+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.bellman_ford_path">bellman_ford_path</a>
242+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.bellman_ford_path_length">bellman_ford_path_length</a>
243+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.dijkstra_path">dijkstra_path</a>
244+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.dijkstra_path_length">dijkstra_path_length</a>
245+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford">single_source_bellman_ford</a>
246+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path">single_source_bellman_ford_path</a>
247+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path_length.html#networkx.algorithms.shortest_paths.weighted.single_source_bellman_ford_path_length">single_source_bellman_ford_path_length</a>
248+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra">single_source_dijkstra</a>
249+
├─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path">single_source_dijkstra_path</a>
250+
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path_length.html#networkx.algorithms.shortest_paths.weighted.single_source_dijkstra_path_length">single_source_dijkstra_path_length</a>
251251
<a href="https://networkx.org/documentation/stable/reference/algorithms/tournament.html#module-networkx.algorithms.tournament">tournament</a>
252252
└─ <a href="https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.tournament.tournament_matrix.html#networkx.algorithms.tournament.tournament_matrix">tournament_matrix</a>
253253
<a href="https://networkx.org/documentation/stable/reference/algorithms/traversal.html">traversal</a>

nx_cugraph/algorithms/bipartite/matrix.py

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,27 @@
44
import networkx as nx
55
import numpy as np
66

7+
from nx_cugraph import _nxver
78
from nx_cugraph.convert import _to_graph
89
from nx_cugraph.generators._utils import _create_using_class
910
from nx_cugraph.utils import index_dtype, networkx_algorithm
1011

1112
__all__ = ["biadjacency_matrix", "from_biadjacency_matrix"]
1213

14+
# row_order and column_order were added in networkx 3.6.1, treat them as extra params
15+
# for function signature checks when using networkx < 3.6.1.
16+
if _nxver < (3, 6, 1):
17+
_row_col_order_extra_params = {
18+
"row_order : list, optional": (
19+
"unused, for compatibility with networkx >= 3.6.1"
20+
),
21+
"column_order : list, optional": (
22+
"unused, for compatibility with networkx >= 3.6.1"
23+
),
24+
}
25+
else:
26+
_row_col_order_extra_params = {}
27+
1328

1429
@networkx_algorithm(version_added="25.06")
1530
def biadjacency_matrix(
@@ -76,8 +91,20 @@ def biadjacency_matrix(
7691
raise nx.NetworkXError(f"Unknown sparse matrix format: {format}") from exc
7792

7893

79-
@networkx_algorithm(version_added="25.06", fallback=True, create_using_arg=1)
80-
def from_biadjacency_matrix(A, create_using=None, edge_attribute="weight"):
94+
@networkx_algorithm(
95+
extra_params={**_row_col_order_extra_params},
96+
fallback=True,
97+
create_using_arg=1,
98+
version_added="25.06",
99+
)
100+
def from_biadjacency_matrix(
101+
A, create_using=None, edge_attribute="weight", *, row_order=None, column_order=None
102+
):
103+
if row_order is not None or column_order is not None:
104+
raise NotImplementedError(
105+
f"row_order={row_order} and column_order={column_order} not supported;"
106+
" only row_order=None and column_order=None are currently supported"
107+
)
81108
graph_class, inplace = _create_using_class(create_using)
82109
nrows, ncols = A.shape
83110
if A.format != "coo":
@@ -115,3 +142,20 @@ def from_biadjacency_matrix(A, create_using=None, edge_attribute="weight"):
115142
if inplace:
116143
return create_using._become(G)
117144
return G
145+
146+
147+
@from_biadjacency_matrix._can_run
148+
def _(
149+
A,
150+
create_using=None,
151+
edge_attribute="weight",
152+
*,
153+
row_order=None,
154+
column_order=None,
155+
):
156+
if row_order is not None or column_order is not None:
157+
return (
158+
f"row_order={row_order} and column_order={column_order} not supported; "
159+
"only row_order=None and column_order=None are currently supported"
160+
)
161+
return True

0 commit comments

Comments
 (0)