Oi. Topology. Graph
(oi v0.7.0)
Copy Markdown
The pure mathematical representation of the DAG.
Summary
Functions
Get all input edges pointing to a given node
Get all output edges emanating from a given node.
Validate graph structure and return topological order on success.
Types
@type t(container_type) :: %Oi.Topology.Graph{ edges: MapSet.t(Oi.Topology.Graph.Edge.t()), in_edges: %{ required(Oi.Topology.Graph.Node.id()) => [Oi.Topology.Graph.Edge.t()] }, nodes: %{ required(Oi.Topology.Graph.Node.id()) => Oi.Topology.Graph.Node.t(container_type) }, out_edges: %{ required(Oi.Topology.Graph.Node.id()) => [Oi.Topology.Graph.Edge.t()] } }
Functions
@spec get_in_edges(t(), Oi.Topology.Graph.Node.id()) :: [Oi.Topology.Graph.Edge.t()]
Get all input edges pointing to a given node
@spec get_out_edges(t(), Oi.Topology.Graph.Node.id()) :: [Oi.Topology.Graph.Edge.t()]
Get all output edges emanating from a given node.
@spec topological_sort(t()) :: {:ok, [Oi.Topology.Graph.Node.id()]} | {:error, [Oi.Topology.Graph.Node.id()]}
@spec validate(t()) :: {:ok, [Oi.Topology.Graph.Node.id()]} | {:error, [{atom(), term()}]}
Validate graph structure and return topological order on success.
Returns {:ok, sorted_node_ids} or {:error, reasons} where
reasons is a list of {tag, detail} tuples.
Checks:
- No orphan edges —
from_node/to_nodemust exist ingraph.nodes - Port membership —
from_portmust be in the source node'soutputs,to_portmust be in the target node'sinputs - No cycles (topological sort)