# `Yog.Multi.Mermaid`
[🔗](https://github.com/code-shoily/yog_ex/blob/v0.98.0/lib/yog/multi/mermaid.ex#L1)

Mermaid.js format export for visualizing multigraphs.

This module exports multigraphs (graphs with support for parallel edges)
to Mermaid syntax. It mirrors the capabilities of `Yog.Render.Mermaid`
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.Mermaid.default_options() |
      edge_attributes: fn from, to, edge_id, weight ->
        if edge_id == 5 do
          [{:stroke, "#d32f2f"}, {:stroke_width, "3px"}]
        else
          []
        end
      end
    }

## Subgraphs

Group nodes visually using subgraphs:

    options = %{
      Yog.Multi.Mermaid.default_options() |
      subgraphs: [
        %{
          name: "Group A",
          label: "Cluster A",
          node_ids: [1, 2, 3]
        }
      ]
    }

# `css_length`

```elixir
@type css_length() ::
  {:px, integer()}
  | {:em, float()}
  | {:rem, float()}
  | {:percent, float()}
  | {:custom, String.t()}
```

CSS length unit for styling.

# `direction`

```elixir
@type direction() :: :td | :lr | :bt | :rl
```

Direction for graph layout

# `node_shape`

```elixir
@type node_shape() ::
  :rounded_rect
  | :stadium
  | :subroutine
  | :cylinder
  | :circle
  | :asymmetric
  | :rhombus
  | :hexagon
  | :parallelogram
  | :parallelogram_alt
  | :trapezoid
  | :trapezoid_alt
```

Node shape options for Mermaid diagrams.

See `Yog.Render.Mermaid` for the full list of shapes.

# `options`

```elixir
@type options() :: %{
  node_label: (Yog.Model.node_id(), any() -&gt; String.t()),
  edge_label: (Yog.Multi.Graph.edge_id(), any() -&gt; 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() -&gt; [{atom(), String.t()}]),
  edge_attributes: (Yog.Model.node_id(),
                    Yog.Model.node_id(),
                    Yog.Multi.Graph.edge_id(),
                    any() -&gt;
                      [{atom(), String.t()}]),
  subgraphs: [subgraph()] | nil,
  direction: direction(),
  node_shape: node_shape() | (Yog.Model.node_id(), any() -&gt; node_shape()),
  default_fill: String.t() | nil,
  default_stroke: String.t() | nil,
  default_stroke_width: css_length() | nil,
  default_font_color: String.t() | nil,
  default_link_stroke: String.t() | nil,
  highlight_fill: String.t(),
  highlight_stroke: String.t(),
  highlight_stroke_width: css_length(),
  link_thickness: css_length(),
  highlight_link_stroke: String.t(),
  highlight_link_stroke_width: css_length()
}
```

Options for customizing multigraph Mermaid rendering

# `subgraph`

```elixir
@type subgraph() :: %{
  name: String.t(),
  label: String.t() | nil,
  node_ids: [Yog.Model.node_id()] | nil
}
```

A subgraph for grouping nodes visually in the diagram.

# `community_to_options`

```elixir
@spec community_to_options(Yog.Community.Result.t(), options()) :: options()
```

Creates Mermaid options that color nodes by community assignment.

Each community gets a distinct color from a generated palette.

# `cut_to_options`

```elixir
@spec cut_to_options(Yog.Flow.MinCutResult.t(), options()) :: options()
```

Creates Mermaid options that color the source and sink sides of a min-cut.

# `default_options`

```elixir
@spec default_options() :: options()
```

Creates default Mermaid options with multigraph labeling capabilities.

# `default_options_with`

```elixir
@spec default_options_with(
  node_label: (Yog.Model.node_id(), any() -&gt; String.t()),
  edge_label: (any() -&gt; String.t())
) :: options()
```

Creates default Mermaid options with custom label formatters for both nodes and edges.

# `default_options_with_edge_formatter`

```elixir
@spec default_options_with_edge_formatter((any() -&gt; String.t())) :: options()
```

Creates default Mermaid options with a custom edge formatter.

Use this when your multigraph has non-String edge data.

# `default_options_without_labels`

```elixir
@spec default_options_without_labels() :: options()
```

Creates default Mermaid options with all edge labels hidden.

Use this when you want a clean diagram without edge annotations.

# `matching_to_options`

```elixir
@spec matching_to_options(
  %{required(Yog.Model.node_id()) =&gt; Yog.Model.node_id()},
  options()
) ::
  options()
```

Creates Mermaid options that highlight matched edges from a matching result.

# `mst_to_options`

```elixir
@spec mst_to_options(Yog.MST.Result.t(), options()) :: options()
```

Creates Mermaid options that highlight an MST result.

# `path_to_options`

```elixir
@spec path_to_options(map(), options()) :: options()
```

Converts a shortest path result to highlighted Mermaid options.

Creates a copy of the base options with the path's nodes and edges
set to be highlighted.

# `theme`

```elixir
@spec theme(atom()) :: options()
```

Returns a pre-configured theme as Mermaid options for multigraphs.

Available themes:
- `:default` — Yellow highlight, orange stroke (same as `default_options/0`)
- `:dark` — Dark-friendly colors with neon accent colors
- `:minimal` — Clean wireframe look with no fills and thin lines
- `:presentation` — Large strokes and bold colors for slides and demos

# `to_mermaid`

```elixir
@spec to_mermaid(Yog.Multi.Graph.t(), options()) :: String.t()
```

Converts a multigraph (`Yog.Multi.Graph`) to Mermaid syntax.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
