"""Type classes for :mod:`mode.utils.graphs`."""
import abc
from typing import (
Any, Generic, IO, Iterable, Mapping, MutableMapping, Sequence, TypeVar,
)
__all__ = ['GraphFormatterT', 'DependencyGraphT']
_T = TypeVar('_T')
[docs]class DependencyGraphT(Generic[_T], Mapping[_T, _T]):
"""Type class for dependency graphs."""
adjacent: MutableMapping[_T, _T]
@abc.abstractmethod
def __init__(self,
it: Iterable[_T] = None,
formatter: GraphFormatterT[_T] = None) -> None:
...
[docs] @abc.abstractmethod
def add_arc(self, obj: _T) -> None:
...
[docs] @abc.abstractmethod
def add_edge(self, A: _T, B: _T) -> None:
...
[docs] @abc.abstractmethod
def connect(self, graph: 'DependencyGraphT') -> None:
...
[docs] @abc.abstractmethod
def topsort(self) -> Sequence:
...
[docs] @abc.abstractmethod
def valency_of(self, obj: _T) -> int:
...
[docs] @abc.abstractmethod
def update(self, it: Iterable) -> None:
...
[docs] @abc.abstractmethod
def edges(self) -> Iterable:
...
[docs] @abc.abstractmethod
def to_dot(self, fh: IO, *, formatter: GraphFormatterT[_T] = None) -> None:
...