Table of Contents

Class GraphMermaidExtensions

Namespace
Graph1x.Serialization
Assembly
Graph1x.dll

Exports graphs to Mermaid flowchart syntax. Output is deterministic (vertices in insertion order, edges in the graph's enumeration order — grouped by source vertex — and \n line endings) so it can be asserted, diffed, and cached. Mermaid node identifiers cannot be arbitrary strings, so nodes get synthetic identifiers (v0, v1, … in insertion order) with the display label attached at declaration; labels are escaped, so arbitrary vertex strings are safe.

public static class GraphMermaidExtensions
Inheritance
GraphMermaidExtensions
Inherited Members

Methods

ToMermaid<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)

Renders the graph as a Mermaid flowchart with default options.

public static string ToMermaid<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to render.

Returns

string

The Mermaid document.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

ToMermaid<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>, MermaidExportOptions<TVertex, TEdge>)

Renders the graph as a Mermaid flowchart.

public static string ToMermaid<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph, MermaidExportOptions<TVertex, TEdge> options) where TVertex : notnull where TEdge : IEdge<TVertex>

Parameters

graph IReadOnlyGraph<TVertex, TEdge>

The graph to render.

options MermaidExportOptions<TVertex, TEdge>

Rendering options.

Returns

string

The Mermaid document: --> edges for directed graphs, --- for undirected ones.

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

Exceptions

ArgumentNullException

Either argument is null.