Skip to content

Commit 65b8a85

Browse files
authored
Add annotations to networkx.algorithms.approximation.treewidth (#14983)
1 parent d96c888 commit 65b8a85

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Callable, Mapping
3+
from typing import Generic
24

35
from networkx.classes.graph import Graph, _Node
46
from networkx.utils.backends import _dispatchable
57

68
__all__ = ["treewidth_min_degree", "treewidth_min_fill_in"]
79

810
@_dispatchable
9-
def treewidth_min_degree(G: Graph[_Node]): ...
11+
def treewidth_min_degree(G: Graph[_Node]) -> tuple[int, Graph[frozenset[_Node]]]: ...
1012
@_dispatchable
11-
def treewidth_min_fill_in(G: Graph[_Node]): ...
13+
def treewidth_min_fill_in(G: Graph[_Node]) -> tuple[int, Graph[frozenset[_Node]]]: ...
1214

13-
class MinDegreeHeuristic:
15+
class MinDegreeHeuristic(Generic[_Node]):
1416
count: Incomplete
1517

16-
def __init__(self, graph) -> None: ...
17-
def best_node(self, graph): ...
18+
def __init__(self, graph: Graph[_Node]) -> None: ...
19+
def best_node(self, graph: Mapping[_Node, set[_Node]]) -> _Node | None: ...
1820

19-
def min_fill_in_heuristic(graph_dict) -> Incomplete | None: ...
21+
def min_fill_in_heuristic(graph_dict: Mapping[_Node, set[_Node]]) -> _Node | None: ...
2022
@_dispatchable
21-
def treewidth_decomp(G: Graph[_Node], heuristic=...) -> tuple[int, Graph[_Node]]: ...
23+
def treewidth_decomp(
24+
G: Graph[_Node], heuristic: Callable[[dict[_Node, set[_Node]]], _Node | None] = ...
25+
) -> tuple[int, Graph[frozenset[_Node]]]: ...

0 commit comments

Comments
 (0)