mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-06 21:43:59 +08:00
@@ -1,4 +1,3 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, Mapping, MutableMapping
|
||||
from functools import cached_property
|
||||
from typing import Any, ClassVar, TypeVar, overload
|
||||
@@ -7,7 +6,7 @@ from typing_extensions import Self, TypeAlias
|
||||
import numpy
|
||||
from networkx.classes.coreviews import AdjacencyView, AtlasView
|
||||
from networkx.classes.digraph import DiGraph
|
||||
from networkx.classes.reportviews import DegreeView, DiDegreeView, NodeView, OutEdgeView
|
||||
from networkx.classes.reportviews import DegreeView, EdgeView, NodeView
|
||||
|
||||
_Node = TypeVar("_Node", bound=Hashable)
|
||||
_NodeWithData: TypeAlias = tuple[_Node, dict[str, Any]]
|
||||
@@ -38,12 +37,14 @@ class Graph(Collection[_Node]):
|
||||
graph_attr_dict_factory: ClassVar[_MapFactory]
|
||||
|
||||
graph: dict[str, Any]
|
||||
__networkx_cache__: dict[str, Any]
|
||||
|
||||
def to_directed_class(self) -> type[DiGraph[_Node]]: ...
|
||||
def to_undirected_class(self) -> type[Graph[_Node]]: ...
|
||||
def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr) -> None: ...
|
||||
def __init__(self, incoming_graph_data: _Data[_Node] | None = None, **attr: Any) -> None: ... # attr: key=value pairs
|
||||
@cached_property
|
||||
def adj(self) -> AdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
|
||||
def adj(self) -> AdjacencyView[_Node, _Node, Mapping[str, Any]]: ...
|
||||
# This object is a read-only dict-like structure
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
@name.setter
|
||||
@@ -53,7 +54,7 @@ class Graph(Collection[_Node]):
|
||||
def __contains__(self, n: object) -> bool: ...
|
||||
def __len__(self) -> int: ...
|
||||
def add_node(self, node_for_adding: _Node, **attr: Any) -> None: ... # attr: Set or change node attributes using key=value
|
||||
def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ...
|
||||
def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr: Any) -> None: ... # attr: key=value pairs
|
||||
def remove_node(self, n: _Node) -> None: ...
|
||||
def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ...
|
||||
@cached_property
|
||||
@@ -61,12 +62,14 @@ class Graph(Collection[_Node]):
|
||||
def number_of_nodes(self) -> int: ...
|
||||
def order(self) -> int: ...
|
||||
def has_node(self, n: _Node) -> bool: ...
|
||||
# attr: Edge data (or labels or objects) can be assigned using keyword arguments
|
||||
def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Any) -> None: ...
|
||||
def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr) -> None: ...
|
||||
# attr: Edge data (or labels or objects) can be assigned using keyword arguments
|
||||
def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr: Any) -> None: ...
|
||||
# attr: Edge data (or labels or objects) can be assigned using keyword arguments
|
||||
def add_weighted_edges_from(
|
||||
self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = "weight", **attr
|
||||
self, ebunch_to_add: Iterable[tuple[_Node, _Node, float]], weight: str = "weight", **attr: Any
|
||||
) -> None: ...
|
||||
# attr: Edge attributes to add/update for all edges.
|
||||
def remove_edge(self, u: _Node, v: _Node) -> None: ...
|
||||
def remove_edges_from(self, ebunch: Iterable[_EdgePlus[_Node]]) -> None: ...
|
||||
@overload
|
||||
@@ -78,11 +81,12 @@ class Graph(Collection[_Node]):
|
||||
def has_edge(self, u: _Node, v: _Node) -> bool: ...
|
||||
def neighbors(self, n: _Node) -> Iterator[_Node]: ...
|
||||
@cached_property
|
||||
def edges(self) -> OutEdgeView[_Node]: ...
|
||||
def get_edge_data(self, u: _Node, v: _Node, default=None) -> Mapping[str, Incomplete]: ...
|
||||
def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Incomplete]]]]: ...
|
||||
def edges(self) -> EdgeView[_Node]: ...
|
||||
def get_edge_data(self, u: _Node, v: _Node, default: Any = None) -> Mapping[str, Any]: ...
|
||||
# default: any Python object
|
||||
def adjacency(self) -> Iterator[tuple[_Node, Mapping[_Node, Mapping[str, Any]]]]: ...
|
||||
@cached_property
|
||||
def degree(self) -> DegreeView[_Node] | DiDegreeView[_Node]: ... # Include subtypes' possible return types
|
||||
def degree(self) -> int | DegreeView[_Node]: ...
|
||||
def clear(self) -> None: ...
|
||||
def clear_edges(self) -> None: ...
|
||||
def is_multigraph(self) -> bool: ...
|
||||
|
||||
@@ -15,7 +15,8 @@ class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]):
|
||||
@cached_property
|
||||
def pred(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
|
||||
@cached_property
|
||||
def edges(self) -> OutMultiEdgeView[_Node]: ...
|
||||
def edges(self) -> OutMultiEdgeView[_Node]: ... # type: ignore[override]
|
||||
# Returns: OutMultiEdgeView
|
||||
@cached_property
|
||||
def out_edges(self) -> OutMultiEdgeView[_Node]: ...
|
||||
@cached_property
|
||||
|
||||
@@ -1,33 +1,46 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Mapping
|
||||
from collections.abc import Hashable, Mapping
|
||||
from functools import cached_property
|
||||
from typing import ClassVar
|
||||
from typing_extensions import TypeAlias
|
||||
from typing import Any, ClassVar, overload
|
||||
from typing_extensions import TypeAlias, TypeVar
|
||||
|
||||
from networkx.classes.coreviews import MultiAdjacencyView
|
||||
from networkx.classes.graph import Graph, _MapFactory, _Node
|
||||
from networkx.classes.multidigraph import MultiDiGraph
|
||||
from networkx.classes.reportviews import OutMultiEdgeView
|
||||
from networkx.classes.reportviews import MultiEdgeView
|
||||
|
||||
_MultiEdge: TypeAlias = tuple[_Node, _Node, int] # noqa: Y047
|
||||
|
||||
_Any = TypeVar("_Any")
|
||||
|
||||
__all__ = ["MultiGraph"]
|
||||
|
||||
class MultiGraph(Graph[_Node]):
|
||||
edge_key_dict_factory: ClassVar[_MapFactory]
|
||||
def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr) -> None: ...
|
||||
def __init__(self, incoming_graph_data=None, multigraph_input: bool | None = None, **attr: Any) -> None: ...
|
||||
@cached_property
|
||||
def adj(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
|
||||
def adj(self) -> MultiAdjacencyView[_Node, _Node, Mapping[str, Any]]: ...
|
||||
def new_edge_key(self, u: _Node, v: _Node) -> int: ...
|
||||
def add_edge(self, u_for_edge, v_for_edge, key=None, **attr): ... # type: ignore[override] # Has an additional `key` keyword argument
|
||||
def add_edge( # type: ignore[override]
|
||||
self, u_for_edge: _Node, v_for_edge: _Node, key: Hashable | int | None = None, **attr: Any
|
||||
) -> Hashable | int: ...
|
||||
# key : hashable identifier, optional (default=lowest unused integer)
|
||||
def remove_edge(self, u, v, key=None): ...
|
||||
def has_edge(self, u: _Node, v: _Node, key=None) -> bool: ...
|
||||
def get_edge_data( # type: ignore[override] # Has an additional `key` keyword argument
|
||||
self, u, v, key=None, default=None
|
||||
) -> Mapping[str, Incomplete]: ...
|
||||
@overload # type: ignore[override]
|
||||
def get_edge_data(self, u: _Node, v: _Node, key: Hashable, default: _Any | None = None) -> Mapping[str, Any] | _Any: ...
|
||||
# key : hashable identifier, optional (default=None).
|
||||
# default : any Python object (default=None). Value to return if the specific edge (u, v, key) is not found.
|
||||
# Returns: The edge attribute dictionary.
|
||||
@overload
|
||||
def get_edge_data(
|
||||
self, u: _Node, v: _Node, key: None = None, default: _Any | None = None
|
||||
) -> Mapping[Hashable, Mapping[str, Any] | _Any]: ...
|
||||
# default : any Python object (default=None). Value to return if there are no edges between u and v and no key is specified.
|
||||
# Returns: A dictionary mapping edge keys to attribute dictionaries for each of those edges if no specific key is provided.
|
||||
def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ...
|
||||
def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ...
|
||||
def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ...
|
||||
def number_of_edges(self, u: _Node | None = None, v: _Node | None = None) -> int: ...
|
||||
@cached_property
|
||||
def edges(self) -> OutMultiEdgeView[_Node]: ...
|
||||
def edges(self) -> MultiEdgeView[_Node]: ... # type: ignore[override]
|
||||
# Returns: MultiEdgeView
|
||||
|
||||
Reference in New Issue
Block a user