aryagraph.core.graph.DiGraph#

class aryagraph.core.graph.DiGraph(data: Any = None, *, nodes: Iterable[Any] | None = None, name: str | None = None, **attrs: Any)[source]#

Bases: Graph

Directed simple graph (self-loops allowed, at most one arc per ordered pair).

successors(node: Hashable) → Iterator[Hashable][source]#

Iterate over the heads of arcs leaving node.

predecessors(node: Hashable) → Iterator[Hashable][source]#

Iterate over the tails of arcs entering node.

neighbors(node: Hashable) → Iterator[Hashable][source]#

Successors of node (use all_neighbors() for both directions).

all_neighbors(node: Hashable) → Iterator[Hashable][source]#

Predecessors and successors of node, each listed once.

in_degree(node: Hashable | None = None, weight: str | None = None) → Any[source]#

In-degree of node, or a NodeMap of all in-degrees.

out_degree(node: Hashable | None = None, weight: str | None = None) → Any[source]#

Out-degree of node, or a NodeMap of all out-degrees.

reverse() → DiGraph[source]#

Copy with every arc reversed.

to_undirected(reciprocal: bool = False) → Graph[source]#

Undirected copy; with reciprocal, keep only pairs linked in both directions.

is_dag() → bool[source]#

True when the graph has no directed cycle.

to_dag() → DAG[source]#

Copy as a DAG (raises CycleError if a cycle exists).