-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add annotations for type-specific rustworkx functions (#963)
* WIP: add some annotations * WIP: more annotations * WIP: more annotations * Add centrality functions * Add MST functions * Add layout functions * Minor fix * Work on positional-only arguments * More positional-only arguments * Typos and minor details * All things pass * All simple paths * A-star * More * Minor fix * Black * Add visitors * Some shortest path functions * More floyd warshall * Graph union * Misc graph algos * Positional only * More types * Fix stubs * New methods * Link analysis * EdgeCentralityMapping * Even more functions * Matching * Start organizing in more than one file * Organize centrality and traversal * Organize layout * Organize link analysis and isomorphism * Re-export type-specific functions at the top level of the library * Organize tree module * Organize connectivity module * Remove re-export inside "module"-like files * Reorganize some lost functions * Reorganize matching and more connectivity functions * Organzie random_graph * Almost done * Add i/o functions * Add simple_cycles * Conclude annotations * Fix UP006 errors from ruff * Fix signature typo * Remove Optional and Union for new union syntax * Add new bipartite methods * Add isolates * Add new methods * Avoid future merge conflict --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e2a264b
commit f1d02e3
Showing
30 changed files
with
1,429 additions
and
19 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
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,25 @@ | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
# This file contains only type annotations for PyO3 functions and classes | ||
# For implementation details, see __init__.py and src/cartesian_product.rs | ||
|
||
from .iterators import * | ||
from .graph import PyGraph | ||
from .digraph import PyDiGraph | ||
|
||
def digraph_cartesian_product( | ||
first: PyDiGraph, | ||
second: PyDiGraph, | ||
/, | ||
) -> tuple[PyDiGraph, ProductNodeMap]: ... | ||
def graph_cartesian_product( | ||
first: PyGraph, | ||
second: PyGraph, | ||
/, | ||
) -> tuple[PyGraph, ProductNodeMap]: ... |
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,90 @@ | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
# This file contains only type annotations for PyO3 functions and classes | ||
# For implementation details, see __init__.py and src/centrality.rs | ||
|
||
from .iterators import * | ||
from .graph import PyGraph | ||
from .digraph import PyDiGraph | ||
|
||
from typing import TypeVar, Callable | ||
|
||
_S = TypeVar("_S") | ||
_T = TypeVar("_T") | ||
|
||
def digraph_eigenvector_centrality( | ||
graph: PyDiGraph[_S, _T], | ||
/, | ||
weight_fn: Callable[[_T], float] | None = ..., | ||
default_weight: float = ..., | ||
max_iter: int = ..., | ||
tol: float = ..., | ||
) -> CentralityMapping: ... | ||
def graph_eigenvector_centrality( | ||
graph: PyGraph[_S, _T], | ||
/, | ||
weight_fn: Callable[[_T], float] | None = ..., | ||
default_weight: float = ..., | ||
max_iter: int = ..., | ||
tol: float = ..., | ||
) -> CentralityMapping: ... | ||
def digraph_betweenness_centrality( | ||
graph: PyDiGraph[_S, _T], | ||
/, | ||
normalized: bool = ..., | ||
endpoints: bool = ..., | ||
parallel_threshold: int = ..., | ||
) -> CentralityMapping: ... | ||
def graph_betweenness_centrality( | ||
graph: PyGraph[_S, _T], | ||
/, | ||
normalized: bool = ..., | ||
endpoints: bool = ..., | ||
parallel_threshold: int = ..., | ||
) -> CentralityMapping: ... | ||
def digraph_edge_betweenness_centrality( | ||
graph: PyDiGraph[_S, _T], | ||
/, | ||
normalized: bool = ..., | ||
parallel_threshold: int = ..., | ||
) -> EdgeCentralityMapping: ... | ||
def graph_edge_betweenness_centrality( | ||
graph: PyGraph[_S, _T], | ||
/, | ||
normalized: bool = ..., | ||
parallel_threshold: int = ..., | ||
) -> EdgeCentralityMapping: ... | ||
def digraph_closeness_centrality( | ||
graph: PyDiGraph[_S, _T], | ||
wf_improved: bool = ..., | ||
) -> CentralityMapping: ... | ||
def graph_closeness_centrality( | ||
graph: PyGraph[_S, _T], | ||
wf_improved: bool = ..., | ||
) -> CentralityMapping: ... | ||
def digraph_katz_centrality( | ||
graph: PyDiGraph[_S, _T], | ||
/, | ||
alpha: float | None = ..., | ||
beta: float | None = ..., | ||
weight_fn: Callable[[_T], float] | None = ..., | ||
default_weight: float | None = ..., | ||
max_iter: int | None = ..., | ||
tol: float | None = ..., | ||
) -> CentralityMapping: ... | ||
def graph_katz_centrality( | ||
graph: PyGraph[_S, _T], | ||
/, | ||
alpha: float | None = ..., | ||
beta: float | None = ..., | ||
weight_fn: Callable[[_T], float] | None = ..., | ||
default_weight: float | None = ..., | ||
max_iter: int | None = ..., | ||
tol: float | None = ..., | ||
) -> CentralityMapping: ... |
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,20 @@ | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
# This file contains only type annotations for PyO3 functions and classes | ||
# For implementation details, see __init__.py and src/coloring.rs | ||
|
||
from .graph import PyGraph | ||
from .digraph import PyDiGraph | ||
|
||
def graph_greedy_color(graph: PyGraph, /) -> dict[int, int]: ... | ||
def graph_greedy_edge_color(graph: PyGraph, /) -> dict[int, int]: ... | ||
def graph_is_bipartite(graph: PyGraph) -> bool: ... | ||
def digraph_is_bipartite(graph: PyDiGraph) -> bool: ... | ||
def graph_two_color(graph: PyGraph) -> dict[int, int]: ... | ||
def digraph_two_color(graph: PyDiGraph) -> dict[int, int]: ... |
Oops, something went wrong.