Yog.Multi.DOT (YogEx v0.97.1)

Copy Markdown View Source

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 default DOT options with multigraph labeling capabilities.

Converts a multigraph (Yog.Multi.Graph) to DOT syntax.

Types

arrow_style()

@type arrow_style() ::
  :normal
  | :dot
  | :diamond
  | :odiamond
  | :box
  | :crow
  | :vee
  | :inv
  | :tee
  | :none
  | {:custom, String.t()}

Arrow head/tail style

layout()

@type layout() ::
  :dot
  | :neato
  | :circo
  | :fdp
  | :sfdp
  | :twopi
  | :osage
  | {:custom, String.t()}

Graphviz layout engine

node_shape()

@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

options()

@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

overlap()

@type overlap() :: true | false | :scale | :scalexy | :prism | {:custom, String.t()}

Overlap handling

rank_dir()

@type rank_dir() :: :tb | :lr | :bt | :rl

Graph direction (rank direction)

splines()

@type splines() :: :line | :polyline | :curved | :ortho | :spline | :none

Edge routing style

style()

@type style() ::
  :solid
  | :dashed
  | :dotted
  | :bold
  | :filled
  | :rounded
  | :diagonals
  | :striped
  | :wedged

Visual style

subgraph()

@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

default_options()

@spec default_options() :: options()

Creates default DOT options with multigraph labeling capabilities.

to_dot(graph, options \\ default_options())

@spec to_dot(Yog.Multi.Graph.t(), options()) :: String.t()

Converts a multigraph (Yog.Multi.Graph) to DOT syntax.