Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eb2b783
Merged networkx stubs from python-type-stubs
Avasam May 13, 2025
67402d1
Replace `: Incomplete | None = None` with `=None`
Avasam May 13, 2025
2037be3
Fix failing tests
Avasam May 13, 2025
16f2a66
Support `requires_python` in `runtests.py`
Avasam May 13, 2025
1dad75f
Support `requires_python` in `runtests.py`
Avasam May 13, 2025
1f6be6e
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 13, 2025
d487295
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 14, 2025
72cf2c9
Discard changes to stubs/networkx/networkx/drawing/nx_agraph.pyi
Avasam May 14, 2025
e17709f
Update stubs/networkx/networkx/classes/multidigraph.pyi
Avasam May 14, 2025
47f5f7c
Update stubs/networkx/networkx/classes/digraph.pyi
Avasam May 14, 2025
73dbdbf
Remove accidental extra symbols
Avasam May 16, 2025
8aa5a56
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 16, 2025
a092752
Replace `Graph[Incomplete]` with `Graph[_Node]`
Avasam May 22, 2025
8ab7313
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 22, 2025
071e34d
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 26, 2025
f52e0ce
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Jul 25, 2025
6409a80
Pass tests
Avasam Jul 25, 2025
39f5442
Merge branch 'main' into networkx-merge-from-python-type-stubs
Avasam Aug 5, 2025
33f6249
Discard changes to stubs/networkx/networkx/classes/digraph.pyi
Avasam Aug 20, 2025
cba33cc
Discard changes to stubs/networkx/networkx/classes/graph.pyi
Avasam Aug 20, 2025
fc0104b
Discard changes to stubs/networkx/networkx/classes/multidigraph.pyi
Avasam Aug 20, 2025
764a6d2
Discard changes to stubs/networkx/networkx/classes/multigraph.pyi
Avasam Aug 20, 2025
2ba94b7
Update stubs/networkx/networkx/classes/reportviews.pyi
Avasam Aug 20, 2025
f43c212
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Aug 20, 2025
5bcdc2c
Update stubs/networkx/networkx/algorithms/approximation/traveling_sal…
Avasam Aug 20, 2025
53989c5
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Aug 20, 2025
7c89025
Merge branch 'main' into networkx-merge-from-python-type-stubs
Avasam Sep 26, 2025
26c884f
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Oct 3, 2025
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
6 changes: 5 additions & 1 deletion stubs/networkx/networkx/algorithms/approximation/maxcut.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Iterable

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -12,5 +13,8 @@ def randomized_partitioning(
): ...
@_dispatchable
def one_exchange(
G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None
G: Graph[_Node],
initial_cut: Iterable[Incomplete] | None = None,
seed: int | RandomState | None = None,
weight: str | None = None,
): ...
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def traveling_salesman_problem(
cycle: bool = True,
method: Callable[..., Incomplete] | None = None,
**kwargs,
): ...
) -> list[Incomplete]: ...
@_dispatchable
def asadpour_atsp(
G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ def degree_pearson_correlation_coefficient(
def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ...
@_dispatchable
def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ...
def attribute_ac(M) -> float: ...
16 changes: 11 additions & 5 deletions stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections.abc import Generator
from _typeshed import Incomplete
from collections.abc import Generator, Iterable

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -7,18 +8,23 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli

@_dispatchable
def write_edgelist(
G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8"
G: Graph[_Node],
path,
comments: str = "#",
delimiter: str = " ",
data: bool | Iterable[Incomplete] = True,
encoding: str = "utf-8",
) -> None: ...
@_dispatchable
def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[str]: ...
def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool | Iterable[Incomplete] = True) -> Generator[str]: ...
@_dispatchable
def parse_edgelist(
lines,
comments: str | None = "#",
delimiter: str | None = None,
create_using: Graph[_Node] | None = None,
nodetype=None,
data=True,
data: bool | Iterable[Incomplete] = True,
): ...
@_dispatchable
def read_edgelist(
Expand All @@ -27,7 +33,7 @@ def read_edgelist(
delimiter: str | None = None,
create_using=None,
nodetype=None,
data=True,
data: bool | Iterable[Incomplete] = True,
edgetype=None,
encoding: str | None = "utf-8",
): ...
14 changes: 7 additions & 7 deletions stubs/networkx/networkx/algorithms/bipartite/generators.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Collection

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -20,24 +20,24 @@ __all__ = [
def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ...
@_dispatchable
def configuration_model(
aseq: Iterable[Incomplete],
bseq: Iterable[Incomplete],
aseq: Collection[Incomplete],
bseq: Collection[Incomplete],
create_using: Graph[_Node] | None = None,
seed: int | RandomState | None = None,
): ...
@_dispatchable
def havel_hakimi_graph(aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None): ...
def havel_hakimi_graph(aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None): ...
@_dispatchable
def reverse_havel_hakimi_graph(
aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None
aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None
): ...
@_dispatchable
def alternating_havel_hakimi_graph(
aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None
aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None
): ...
@_dispatchable
def preferential_attachment_graph(
aseq: Iterable[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None
aseq: Collection[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None
): ...
@_dispatchable
def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ...
Expand Down
6 changes: 2 additions & 4 deletions stubs/networkx/networkx/algorithms/bipartite/matching.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete, SupportsGetItem
from _typeshed import Incomplete
from collections.abc import Iterable

from networkx.classes.graph import Graph, _Node
Expand All @@ -11,9 +11,7 @@ def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None =
@_dispatchable
def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def to_vertex_cover(
G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None
): ...
def to_vertex_cover(G: Graph[_Node], matching: Iterable[Incomplete], top_nodes: Iterable[Incomplete] | None = None): ...

maximum_matching = hopcroft_karp_matching

Expand Down
6 changes: 3 additions & 3 deletions stubs/networkx/networkx/algorithms/bipartite/matrix.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Collection

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -9,8 +9,8 @@ __all__ = ["biadjacency_matrix", "from_biadjacency_matrix"]
@_dispatchable
def biadjacency_matrix(
G: Graph[_Node],
row_order: Iterable[_Node],
column_order: Iterable[Incomplete] | None = None,
row_order: Collection[_Node],
column_order: Collection[Incomplete] | None = None,
dtype=None,
weight: str | None = "weight",
format="csr",
Expand Down
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/bipartite/projection.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterable
from collections.abc import Callable, Collection, Iterable

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -15,7 +15,7 @@ __all__ = [
@_dispatchable
def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False): ...
@_dispatchable
def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False): ...
def weighted_projected_graph(B: Graph[_Node], nodes: Collection[Incomplete], ratio: bool = False): ...
@_dispatchable
def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]): ...
@_dispatchable
Expand Down
22 changes: 11 additions & 11 deletions stubs/networkx/networkx/algorithms/boundary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node], None, None]: ...
Expand All @@ -22,7 +22,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ...
Expand All @@ -31,7 +31,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ...
Expand All @@ -40,7 +40,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ...
Expand All @@ -49,7 +49,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ...
Expand All @@ -58,7 +58,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int], None, None]: ...
Expand All @@ -67,7 +67,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int], None, None]: ...
Expand All @@ -76,7 +76,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ...
Expand All @@ -85,7 +85,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ...
Expand All @@ -94,7 +94,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ...
Expand All @@ -103,7 +103,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | Incomplete = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ...
Expand Down
5 changes: 3 additions & 2 deletions stubs/networkx/networkx/algorithms/centrality/closeness.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
from _typeshed import Incomplete
from collections.abc import Mapping

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -13,7 +14,7 @@ def closeness_centrality(
def incremental_closeness_centrality(
G: Graph[_Node],
edge: tuple[Incomplete],
prev_cc: SupportsGetItem[Incomplete, Incomplete] | None = None,
prev_cc: Mapping[Incomplete, Incomplete] | None = None,
insertion: bool | None = True,
wf_improved: bool | None = True,
) -> dict[_Node, float]: ...
5 changes: 3 additions & 2 deletions stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
from _typeshed import Incomplete
from collections.abc import Mapping

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -10,7 +11,7 @@ def eigenvector_centrality(
G: Graph[_Node],
max_iter: int | None = 100,
tol: float | None = 1e-06,
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
nstart: Mapping[Incomplete, Incomplete] | None = None,
weight: str | None = None,
) -> dict[Incomplete, float]: ...
@_dispatchable
Expand Down
3 changes: 2 additions & 1 deletion stubs/networkx/networkx/algorithms/centrality/katz.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
from collections.abc import Iterable

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -12,7 +13,7 @@ def katz_centrality(
beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0,
max_iter: int | None = 1000,
tol: float | None = 1e-06,
nstart: SupportsGetItem[Incomplete, Incomplete] | None = None,
nstart: Iterable[Incomplete] | None = None,
normalized: bool | None = True,
weight: str | None = None,
) -> dict[Incomplete, Incomplete]: ...
Expand Down
5 changes: 3 additions & 2 deletions stubs/networkx/networkx/algorithms/centrality/percolation.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete, SupportsGetItem
from _typeshed import Incomplete
from collections.abc import Mapping

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -9,6 +10,6 @@ __all__ = ["percolation_centrality"]
def percolation_centrality(
G: Graph[_Node],
attribute: str | None = "percolation",
states: SupportsGetItem[Incomplete, Incomplete] | None = None,
states: Mapping[Incomplete, Incomplete] | None = None,
weight: str | None = None,
) -> dict[Incomplete, float]: ...
8 changes: 5 additions & 3 deletions stubs/networkx/networkx/algorithms/clique.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def make_clique_bipartite(
G: Graph[_Node], fpos: bool | None = None, create_using: Graph[_Node] | None = None, name=None
) -> Graph[_Node]: ...
@overload
def node_clique_number(
G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False
def node_clique_number( # type: ignore[overload-overlap]
G: Graph[_Node], nodes: Iterable[_Node] | None = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False
) -> dict[_Node, int]: ...
@overload
def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ...
def node_clique_number(
G: Graph[_Node], nodes: _Node, cliques: Iterable[Incomplete] | None = None, separate_nodes=False
) -> int: ...
def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
@_dispatchable
def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ __all__ = ["kernighan_lin_bisection"]
@_dispatchable
def kernighan_lin_bisection(
G: Graph[_Node],
partition: tuple[Incomplete] | None = None,
partition: tuple[Incomplete, Incomplete] | None = None,
max_iter: int = 10,
weight: str = "weight",
seed: int | RandomState | None = None,
Expand Down
4 changes: 2 additions & 2 deletions stubs/networkx/networkx/algorithms/flow/mincost.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def min_cost_flow_cost(
@_dispatchable
def min_cost_flow(
G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight"
) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ...
@_dispatchable
def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight") -> int | float: ...
@_dispatchable
def max_flow_min_cost(
G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight"
) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ...
) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ...
6 changes: 4 additions & 2 deletions stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from _typeshed import Incomplete
from collections.abc import Generator

from ...classes.graph import Graph, _Node

__all__ = ["ISMAGS"]

class ISMAGS:
Expand All @@ -9,10 +11,10 @@ class ISMAGS:
node_equality: Incomplete
edge_equality: Incomplete

def __init__(self, graph, subgraph, node_match=None, edge_match=None, cache=None) -> None: ...
def __init__(self, graph: Graph[_Node], subgraph: Graph[_Node], node_match=None, edge_match=None, cache=None) -> None: ...
def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ...
def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
def analyze_symmetry(self, graph, node_partitions, edge_colors): ...
def analyze_symmetry(self, graph: Graph[_Node], node_partitions, edge_colors): ...
def is_isomorphic(self, symmetry: bool = False) -> bool: ...
def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ...
def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ...
Expand Down
Loading