Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions stubs/networkx/@tests/test_cases/check_unweighted_paths-py312.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from collections import UserDict
from typing import Any

import networkx as nx


def unweighted_paths_with_custom_attributes(graph: nx.Graph[int, UserDict[str, Any], UserDict[str, Any]]) -> None:
nx.single_source_shortest_path_length(graph, 0)
nx.single_target_shortest_path_length(graph, 2)
nx.all_pairs_shortest_path_length(graph)
nx.bidirectional_shortest_path(graph, 0, 2)
nx.single_source_shortest_path(graph, 0)
nx.single_target_shortest_path(graph, 2)
nx.all_pairs_shortest_path(graph)
nx.predecessor(graph, 0)
24 changes: 15 additions & 9 deletions stubs/networkx/networkx/algorithms/shortest_paths/unweighted.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from collections.abc import Generator

from networkx.classes.graph import Graph, _Node
from networkx.classes.graph import Graph, _EdgeData, _Node, _NodeData
from networkx.utils.backends import _dispatchable

__all__ = [
Expand All @@ -16,28 +16,34 @@ __all__ = [
]

@_dispatchable
def single_source_shortest_path_length(G: Graph[_Node], source: _Node, cutoff: int | None = None) -> dict[Incomplete, int]: ...
def single_source_shortest_path_length(
G: Graph[_Node, _NodeData, _EdgeData], source: _Node, cutoff: int | None = None
) -> dict[Incomplete, int]: ...
@_dispatchable
def single_target_shortest_path_length(
G: Graph[_Node], target: _Node, cutoff: int | None = None
G: Graph[_Node, _NodeData, _EdgeData], target: _Node, cutoff: int | None = None
) -> dict[Incomplete, Incomplete]: ...
@_dispatchable
def all_pairs_shortest_path_length(G: Graph[_Node], cutoff: int | None = None) -> Generator[Incomplete]: ...
def all_pairs_shortest_path_length(G: Graph[_Node, _NodeData, _EdgeData], cutoff: int | None = None) -> Generator[Incomplete]: ...
@_dispatchable
def bidirectional_shortest_path(G: Graph[_Node], source: _Node, target: _Node) -> list[Incomplete]: ...
def bidirectional_shortest_path(G: Graph[_Node, _NodeData, _EdgeData], source: _Node, target: _Node) -> list[Incomplete]: ...
@_dispatchable
def single_source_shortest_path(
G: Graph[_Node], source: _Node, cutoff: int | None = None
G: Graph[_Node, _NodeData, _EdgeData], source: _Node, cutoff: int | None = None
) -> dict[Incomplete, list[Incomplete]]: ...
@_dispatchable
def single_target_shortest_path(
G: Graph[_Node], target: _Node, cutoff: int | None = None
G: Graph[_Node, _NodeData, _EdgeData], target: _Node, cutoff: int | None = None
) -> dict[Incomplete, list[Incomplete]]: ...
@_dispatchable
def all_pairs_shortest_path(
G: Graph[_Node], cutoff: int | None = None
G: Graph[_Node, _NodeData, _EdgeData], cutoff: int | None = None
) -> Generator[tuple[Incomplete, dict[Incomplete, list[Incomplete]]]]: ...
@_dispatchable
def predecessor(
G: Graph[_Node], source: _Node, target: _Node | None = None, cutoff: int | None = None, return_seen: bool | None = None
G: Graph[_Node, _NodeData, _EdgeData],
source: _Node,
target: _Node | None = None,
cutoff: int | None = None,
return_seen: bool | None = None,
) -> dict[_Node, list[_Node]] | list[_Node] | tuple[dict[_Node, list[_Node]], dict[_Node, int]] | tuple[list[_Node], int]: ...
Loading