DOT (Graphviz) format export for visualizing multigraphs.
This module exports multigraphs (graphs with support for parallel edges)
to the DOT language. It mirrors the capabilities of Yog.Render.DOT
but adapts the edge configurations to account for multiple relationships.
Per-Edge Customization
Because multiple edges can exist between the same nodes, callback functions
pass the unique edge_id:
options = %{
Yog.Multi.DOT.default_options() |
edge_attributes: fn from, to, edge_id, weight ->
if edge_id == 5 do
[{:color, "red"}, {:style, "dashed"}]
else
[]
end
end
}
Summary
Types
Arrow head/tail style
Graphviz layout engine
Node shapes
Options for customizing multigraph DOT rendering
Overlap handling
Graph direction (rank direction)
Edge routing style
Visual style
A subgraph (cluster) for grouping nodes visually in the diagram.
Functions
Creates DOT options that color nodes by community assignment.
Creates DOT options that color the source and sink sides of a min-cut.
Creates default DOT options with multigraph labeling capabilities.
Creates default DOT options with custom label formatters for both nodes and edges.
Creates default DOT options with a custom edge formatter.
Creates default DOT options with all edge labels hidden.
Creates DOT options that highlight matched edges from a matching result.
Creates DOT options that highlight an MST result.
Converts a shortest path result to highlighted DOT options.
Returns a pre-configured theme as DOT options for multigraphs.
Converts a multigraph (Yog.Multi.Graph) to DOT syntax.
Types
@type arrow_style() :: :normal | :dot | :diamond | :odiamond | :box | :crow | :vee | :inv | :tee | :none | {:custom, String.t()}
Arrow head/tail style
@type layout() :: :dot | :neato | :circo | :fdp | :sfdp | :twopi | :osage | {:custom, String.t()}
Graphviz layout engine
@type node_shape() :: :box | :box3d | :circle | :cloud | :component | :cylinder | :diamond | :doublecircle | :ellipse | :folder | :hexagon | :house | :invhouse | :invtriangle | :note | :octagon | :parallelogram | :pentagon | :plain | :plaintext | :point | :rect | :rectangle | :square | :tab | :trapezoid | :triangle | :underline | {:custom, String.t()}
Node shapes
@type options() :: %{ node_label: (Yog.Model.node_id(), any() -> String.t()), edge_label: (Yog.Multi.Graph.edge_id(), any() -> String.t()), highlighted_nodes: [Yog.Model.node_id()] | nil, highlighted_edges: [Yog.Multi.Graph.edge_id() | {Yog.Model.node_id(), Yog.Model.node_id()}] | nil, node_attributes: (Yog.Model.node_id(), any() -> [{atom(), String.t()}]), edge_attributes: (Yog.Model.node_id(), Yog.Model.node_id(), Yog.Multi.Graph.edge_id(), any() -> [{atom(), String.t()}]), subgraphs: [subgraph()] | nil, ranks: [{:same | :min | :max | :source | :sink, [Yog.Model.node_id()]}] | nil, graph_name: String.t(), layout: layout() | nil, rankdir: rank_dir() | nil, bgcolor: String.t() | nil, splines: splines() | nil, overlap: overlap() | nil, nodesep: float() | nil, ranksep: float() | nil, node_shape: node_shape(), node_color: String.t(), node_style: style(), node_fontname: String.t(), node_fontsize: integer(), node_fontcolor: String.t(), edge_color: String.t(), edge_style: style(), edge_fontname: String.t(), edge_fontsize: integer(), edge_penwidth: float(), arrowhead: arrow_style() | nil, arrowtail: arrow_style() | nil, highlight_color: String.t(), highlight_penwidth: float() }
Options for customizing multigraph DOT rendering
@type overlap() :: true | false | :scale | :scalexy | :prism | {:custom, String.t()}
Overlap handling
@type rank_dir() :: :tb | :lr | :bt | :rl
Graph direction (rank direction)
@type splines() :: :line | :polyline | :curved | :ortho | :spline | :none
Edge routing style
@type style() ::
:solid
| :dashed
| :dotted
| :bold
| :filled
| :rounded
| :diagonals
| :striped
| :wedged
Visual style
@type subgraph() :: %{ name: String.t(), label: String.t() | nil, node_ids: [Yog.Model.node_id()] | nil, style: style() | nil, fillcolor: String.t() | nil, color: String.t() | nil, subgraphs: [subgraph()] | nil }
A subgraph (cluster) for grouping nodes visually in the diagram.
Functions
@spec community_to_options(Yog.Community.Result.t(), options()) :: options()
Creates DOT options that color nodes by community assignment.
Each community gets a distinct color from a generated palette.
@spec cut_to_options(Yog.Flow.MinCutResult.t(), options()) :: options()
Creates DOT options that color the source and sink sides of a min-cut.
@spec default_options() :: options()
Creates default DOT options with multigraph labeling capabilities.
@spec default_options_with( node_label: (Yog.Model.node_id(), any() -> String.t()), edge_label: (any() -> String.t()) ) :: options()
Creates default DOT options with custom label formatters for both nodes and edges.
Creates default DOT options with a custom edge formatter.
Use this when your multigraph has non-String edge data.
@spec default_options_without_labels() :: options()
Creates default DOT options with all edge labels hidden.
Use this when you want a clean diagram without edge annotations.
@spec matching_to_options( %{required(Yog.Model.node_id()) => Yog.Model.node_id()}, options() ) :: options()
Creates DOT options that highlight matched edges from a matching result.
@spec mst_to_options(Yog.MST.Result.t(), options()) :: options()
Creates DOT options that highlight an MST result.
Converts a shortest path result to highlighted DOT options.
Creates a copy of the base options with the path's nodes and edges set to be highlighted.
Returns a pre-configured theme as DOT options for multigraphs.
Available themes:
:default— Light blue nodes, black edges (same asdefault_options/0):dark— Dark background with neon accent colors:minimal— Clean wireframe look with no fills and thin lines:presentation— Large fonts and bold colors for slides and demos
@spec to_dot(Yog.Multi.Graph.t(), options()) :: String.t()
Converts a multigraph (Yog.Multi.Graph) to DOT syntax.