@@ -35,6 +35,7 @@ from rustworkx import generators # noqa
35
35
from typing_extensions import Self
36
36
37
37
import numpy as np
38
+ import numpy .typing as npt
38
39
import sys
39
40
40
41
if sys .version_info >= (3 , 13 ):
@@ -206,15 +207,15 @@ def digraph_adjacency_matrix(
206
207
default_weight : float = ...,
207
208
null_value : float = ...,
208
209
parallel_edge : str = ...,
209
- ) -> np .ndarray : ...
210
+ ) -> npt . NDArray [ np .float64 ] : ...
210
211
def graph_adjacency_matrix (
211
212
graph : PyGraph [_S , _T ],
212
213
/ ,
213
214
weight_fn : Callable [[_T ], float ] | None = ...,
214
215
default_weight : float = ...,
215
216
null_value : float = ...,
216
217
parallel_edge : str = ...,
217
- ) -> np .ndarray : ...
218
+ ) -> npt . NDArray [ np .float64 ] : ...
218
219
def cycle_basis (graph : PyGraph , / , root : int | None = ...) -> list [list [int ]]: ...
219
220
def articulation_points (graph : PyGraph , / ) -> set [int ]: ...
220
221
def bridges (graph : PyGraph , / ) -> set [tuple [int ]]: ...
@@ -595,14 +596,14 @@ def undirected_gnp_random_graph(
595
596
) -> PyGraph : ...
596
597
def directed_sbm_random_graph (
597
598
sizes : list [int ],
598
- probabilities : np .ndarray ,
599
+ probabilities : npt . NDArray [ np .float64 ] ,
599
600
loops : bool ,
600
601
/ ,
601
602
seed : int | None = ...,
602
603
) -> PyDiGraph : ...
603
604
def undirected_sbm_random_graph (
604
605
sizes : list [int ],
605
- probabilities : np .ndarray ,
606
+ probabilities : npt . NDArray [ np .float64 ] ,
606
607
loops : bool ,
607
608
/ ,
608
609
seed : int | None = ...,
@@ -863,13 +864,13 @@ def digraph_distance_matrix(
863
864
parallel_threshold : int | None = ...,
864
865
as_undirected : bool | None = ...,
865
866
null_value : float | None = ...,
866
- ) -> np .ndarray : ...
867
+ ) -> npt . NDArray [ np .float64 ] : ...
867
868
def graph_distance_matrix (
868
869
graph : PyGraph ,
869
870
/ ,
870
871
parallel_threshold : int | None = ...,
871
872
null_value : float | None = ...,
872
- ) -> np .ndarray : ...
873
+ ) -> npt . NDArray [ np .float64 ] : ...
873
874
def digraph_floyd_warshall (
874
875
graph : PyDiGraph [_S , _T ],
875
876
/ ,
@@ -892,29 +893,29 @@ def digraph_floyd_warshall_numpy(
892
893
as_undirected : bool | None = ...,
893
894
default_weight : float | None = ...,
894
895
parallel_threshold : int | None = ...,
895
- ) -> np .ndarray : ...
896
+ ) -> npt . NDArray [ np .float64 ] : ...
896
897
def graph_floyd_warshall_numpy (
897
898
graph : PyGraph [_S , _T ],
898
899
/ ,
899
900
weight_fn : Callable [[_T ], float ] | None = ...,
900
901
default_weight : float | None = ...,
901
902
parallel_threshold : int | None = ...,
902
- ) -> np .ndarray : ...
903
+ ) -> npt . NDArray [ np .float64 ] : ...
903
904
def digraph_floyd_warshall_successor_and_distance (
904
905
graph : PyDiGraph [_S , _T ],
905
906
/ ,
906
907
weight_fn : Callable [[_T ], float ] | None = ...,
907
908
as_undirected : bool | None = ...,
908
909
default_weight : float | None = ...,
909
910
parallel_threshold : int | None = ...,
910
- ) -> tuple [np .ndarray , np .ndarray ]: ...
911
+ ) -> tuple [npt . NDArray [ np .float64 ], npt . NDArray [ np .float64 ] ]: ...
911
912
def graph_floyd_warshall_successor_and_distance (
912
913
graph : PyGraph [_S , _T ],
913
914
/ ,
914
915
weight_fn : Callable [[_T ], float ] | None = ...,
915
916
default_weight : float | None = ...,
916
917
parallel_threshold : int | None = ...,
917
- ) -> tuple [np .ndarray , np .ndarray ]: ...
918
+ ) -> tuple [npt . NDArray [ np .float64 ], npt . NDArray [ np .float64 ] ]: ...
918
919
def find_negative_cycle (
919
920
graph : PyDiGraph [_S , _T ],
920
921
edge_cost_fn : Callable [[_T ], float ],
@@ -1079,7 +1080,9 @@ class _RustworkxCustomVecIter(Generic[_T_co], Sequence[_T_co], ABC):
1079
1080
def __len__ (self ) -> int : ...
1080
1081
def __ne__ (self , other : object ) -> bool : ...
1081
1082
def __setstate__ (self , state : Sequence [_T_co ]) -> None : ...
1082
- def __array__ (self , dtype : np .dtype | None = ..., copy : bool | None = ...) -> np .ndarray : ...
1083
+ def __array__ (
1084
+ self , dtype : np .dtype [Any ] | None = ..., copy : bool | None = ...
1085
+ ) -> npt .NDArray [Any ]: ...
1083
1086
def __iter__ (self ) -> Iterator [_T_co ]: ...
1084
1087
def __reversed__ (self ) -> Iterator [_T_co ]: ...
1085
1088
@@ -1235,11 +1238,11 @@ class PyGraph(Generic[_S, _T]):
1235
1238
) -> int | None : ...
1236
1239
@staticmethod
1237
1240
def from_adjacency_matrix (
1238
- matrix : np .ndarray , / , null_value : float = ...
1241
+ matrix : npt . NDArray [ np .float64 ] , / , null_value : float = ...
1239
1242
) -> PyGraph [int , float ]: ...
1240
1243
@staticmethod
1241
1244
def from_complex_adjacency_matrix (
1242
- matrix : np .ndarray , / , null_value : complex = ...
1245
+ matrix : npt . NDArray [ np .complex64 ] , / , null_value : complex = ...
1243
1246
) -> PyGraph [int , complex ]: ...
1244
1247
def get_all_edge_data (self , node_a : int , node_b : int , / ) -> list [_T ]: ...
1245
1248
def get_edge_data (self , node_a : int , node_b : int , / ) -> _T : ...
@@ -1400,11 +1403,11 @@ class PyDiGraph(Generic[_S, _T]):
1400
1403
) -> list [_S ]: ...
1401
1404
@staticmethod
1402
1405
def from_adjacency_matrix (
1403
- matrix : np .ndarray , / , null_value : float = ...
1406
+ matrix : npt . NDArray [ np .float64 ] , / , null_value : float = ...
1404
1407
) -> PyDiGraph [int , float ]: ...
1405
1408
@staticmethod
1406
1409
def from_complex_adjacency_matrix (
1407
- matrix : np .ndarray , / , null_value : complex = ...
1410
+ matrix : npt . NDArray [ np .complex64 ] , / , null_value : complex = ...
1408
1411
) -> PyDiGraph [int , complex ]: ...
1409
1412
def get_all_edge_data (self , node_a : int , node_b : int , / ) -> list [_T ]: ...
1410
1413
def get_edge_data (self , node_a : int , node_b : int , / ) -> _T : ...
0 commit comments