Internal graph representation for the rendering pipeline.
Users should build graphs with Graph from libgraph and pass them to
Boxart.render/2. This module handles the conversion via from_libgraph/2.
Summary
Functions
Appends an edge to the graph.
Adds a node to the graph.
Finds a subgraph by its id, searching recursively through nested children.
Finds the innermost subgraph containing node_id.
Converts a libgraph Graph.t() into the internal representation.
Returns ids of nodes reachable via outgoing edges from node_id, in edge order.
Returns root node ids — nodes with no incoming edges, in definition order.
Returns true if the direction flows horizontally.
Normalizes a direction to its canonical form (:bt → :tb, :rl → :lr, :td → :tb).
Returns true if the direction is reversed (bottom-to-top or right-to-left).
Returns true if the direction flows vertically.
Returns a copy of the graph with the given direction.
Types
@type arrow_type() :: :arrow | :circle | :cross
@type direction() :: :tb | :td | :lr | :bt | :rl
@type edge_style() :: :solid | :dotted | :thick | :invisible
@type node_shape() ::
:rectangle
| :rounded
| :stadium
| :subroutine
| :diamond
| :hexagon
| :circle
| :double_circle
| :asymmetric
| :cylinder
| :parallelogram
| :parallelogram_alt
| :trapezoid
| :trapezoid_alt
| :start_state
| :end_state
| :fork_join
| :junction
@type t() :: %Boxart.Graph{ direction: direction(), edges: [Boxart.Graph.Edge.t()], node_order: [String.t()], nodes: %{required(String.t()) => Boxart.Graph.Node.t()}, subgraphs: [Boxart.Graph.Subgraph.t()] }
Functions
@spec add_edge(t(), Boxart.Graph.Edge.t()) :: t()
Appends an edge to the graph.
@spec add_node(t(), Boxart.Graph.Node.t()) :: t()
Adds a node to the graph.
If a node with the same id already exists, merges non-default fields from the new node into the existing one.
@spec find_subgraph_by_id(t(), String.t()) :: Boxart.Graph.Subgraph.t() | nil
Finds a subgraph by its id, searching recursively through nested children.
@spec find_subgraph_for_node(t(), String.t()) :: Boxart.Graph.Subgraph.t() | nil
Finds the innermost subgraph containing node_id.
Converts a libgraph Graph.t() into the internal representation.
Vertex labels are keyword lists. Recognized keys:
:label— display text (defaults toinspect(vertex)):shape— node shape atom (default::rectangle):source— raw source code string (renders as a code block instead of label):start_line— starting line number for code display (default:1):language— language atom for syntax highlighting (e.g.:elixir)
Edge labels become the display text on the edge.
Options
:direction— layout direction (default::td)
Returns ids of nodes reachable via outgoing edges from node_id, in edge order.
Returns root node ids — nodes with no incoming edges, in definition order.
Falls back to the first defined node when every node has incoming edges.
Returns true if the direction flows horizontally.
@spec normalized(direction()) :: :tb | :lr
Normalizes a direction to its canonical form (:bt → :tb, :rl → :lr, :td → :tb).
Returns true if the direction is reversed (bottom-to-top or right-to-left).
Returns true if the direction flows vertically.
Returns a copy of the graph with the given direction.