Mermaid Module
Mermaid diagram rendering.
Provides functions to export graphs in Mermaid syntax for embedding in markdown documents.
Example
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
namespace Yog
namespace Yog.IO
module Model
from Yog
<summary> Core graph data structures and basic operations for the yog library. This module defines the fundamental `Graph` type and provides all basic operations for creating and manipulating graphs. The graph uses an adjacency list representation with dual indexing (both outgoing and incoming edges) for efficient traversal in both directions. </summary>
<summary> Core graph data structures and basic operations for the yog library. This module defines the fundamental `Graph` type and provides all basic operations for creating and manipulating graphs. The graph uses an adjacency list representation with dual indexing (both outgoing and incoming edges) for efficient traversal in both directions. </summary>
val graph: Graph<string,int>
val empty: graphType: GraphType -> Graph<'n,'e>
<summary> Creates a new empty graph of the specified type. ## Example ```fsharp let graph = Model.empty Directed ``` </summary>
<summary> Creates a new empty graph of the specified type. ## Example ```fsharp let graph = Model.empty Directed ``` </summary>
union case GraphType.Directed: GraphType
<summary> A directed graph where edges have a direction from source to destination. </summary>
<summary> A directed graph where edges have a direction from source to destination. </summary>
val addNode: id: NodeId -> data: 'n -> graph: Graph<'n,'e> -> Graph<'n,'e>
<summary> Adds a node to the graph with the given ID and data. If a node with this ID already exists, its data will be replaced. ## Example ```fsharp graph |> addNode 1 "Node A" |> addNode 2 "Node B" ``` </summary>
<summary> Adds a node to the graph with the given ID and data. If a node with this ID already exists, its data will be replaced. ## Example ```fsharp graph |> addNode 1 "Node A" |> addNode 2 "Node B" ``` </summary>
val addEdge: src: NodeId -> dst: NodeId -> weight: 'e -> graph: Graph<'n,'e> -> Graph<'n,'e>
<summary> Adds an edge to the graph with the given weight. For directed graphs, adds a single edge from src to dst. For undirected graphs, adds edges in both directions. > **Note:** If `src` or `dst` have not been added via `addNode`, > the edge will still be created in the edge dictionaries, but the > nodes will be missing from `graph.Nodes`. This creates "ghost nodes" > that are traversable but invisible to functions that iterate over > nodes (e.g. `order`, `allNodes`). Use `addEdgeEnsured` to > auto-create missing endpoints with a default value. ## Example ```fsharp graph |> addEdge 1 2 10 ``` </summary>
<summary> Adds an edge to the graph with the given weight. For directed graphs, adds a single edge from src to dst. For undirected graphs, adds edges in both directions. > **Note:** If `src` or `dst` have not been added via `addNode`, > the edge will still be created in the edge dictionaries, but the > nodes will be missing from `graph.Nodes`. This creates "ghost nodes" > that are traversable but invisible to functions that iterate over > nodes (e.g. `order`, `allNodes`). Use `addEdgeEnsured` to > auto-create missing endpoints with a default value. ## Example ```fsharp graph |> addEdge 1 2 10 ``` </summary>
val mermaid: string
module Mermaid
from Yog.IO
<summary> Mermaid diagram rendering. Provides functions to export graphs in Mermaid syntax for embedding in markdown documents. ## Example ```fsharp open Yog.IO open Yog.Model let graph = empty Directed |> addNode 1 "Start" |> addNode 2 "End" |> addEdge 1 2 5 // Export to Mermaid for markdown let mermaid = Mermaid.render Mermaid.defaultOptions graph printfn "```mermaid\n%s\n```" mermaid ``` </summary>
<summary> Mermaid diagram rendering. Provides functions to export graphs in Mermaid syntax for embedding in markdown documents. ## Example ```fsharp open Yog.IO open Yog.Model let graph = empty Directed |> addNode 1 "Start" |> addNode 2 "End" |> addEdge 1 2 5 // Export to Mermaid for markdown let mermaid = Mermaid.render Mermaid.defaultOptions graph printfn "```mermaid\n%s\n```" mermaid ``` </summary>
val render: options: Mermaid.Options<'n,'e> -> graph: Graph<'n,'e> -> string
<summary> Converts a graph to Mermaid diagram syntax. Mermaid diagrams can be embedded directly in markdown and rendered by many documentation tools (GitHub, GitLab, Notion, etc.). **Time Complexity:** O(V + E) ## Example ```fsharp let graph = empty Directed |> addNode 1 "Start" |> addNode 2 "Process" |> addNode 3 "End" |> addEdge 1 2 5 |> addEdge 2 3 3 // Highlight a path let options = { Mermaid.defaultOptions with HighlightedNodes = Set.ofList [1; 2; 3] HighlightedEdges = Set.ofList [(1, 2); (2, 3)] } let diagram = Mermaid.render options graph // graph TD // classDef highlight fill:#ffeb3b,stroke:#f57c00,stroke-width:3px // 1["Start"]:::highlight // 2["Process"]:::highlight // 3["End"]:::highlight // 1 -->|"5"| 2:::highlightEdge // 2 -->|"3"| 3:::highlightEdge ``` ## Use Cases - Documentation and README files - Wiki pages - Presentation slides - Quick prototyping and sharing </summary>
<summary> Converts a graph to Mermaid diagram syntax. Mermaid diagrams can be embedded directly in markdown and rendered by many documentation tools (GitHub, GitLab, Notion, etc.). **Time Complexity:** O(V + E) ## Example ```fsharp let graph = empty Directed |> addNode 1 "Start" |> addNode 2 "Process" |> addNode 3 "End" |> addEdge 1 2 5 |> addEdge 2 3 3 // Highlight a path let options = { Mermaid.defaultOptions with HighlightedNodes = Set.ofList [1; 2; 3] HighlightedEdges = Set.ofList [(1, 2); (2, 3)] } let diagram = Mermaid.render options graph // graph TD // classDef highlight fill:#ffeb3b,stroke:#f57c00,stroke-width:3px // 1["Start"]:::highlight // 2["Process"]:::highlight // 3["End"]:::highlight // 1 -->|"5"| 2:::highlightEdge // 2 -->|"3"| 3:::highlightEdge ``` ## Use Cases - Documentation and README files - Wiki pages - Presentation slides - Quick prototyping and sharing </summary>
val defaultOptions<'n,'e> : Mermaid.Options<'n,'e>
<summary> Default configuration for Mermaid output. Uses node ID as a label and edge weight as a string. </summary>
<summary> Default configuration for Mermaid output. Uses node ID as a label and edge weight as a string. </summary>
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Types
| Type | Description |
|
Options for customizing Mermaid diagram rendering. |
Functions and values
| Function or value |
Description
|
||
|
Default configuration for Mermaid output. Uses node ID as a label and edge weight as a string.
|
||
|
Converts a graph to Mermaid diagram syntax. Mermaid diagrams can be embedded directly in markdown and rendered by many documentation tools (GitHub, GitLab, Notion, etc.). Time Complexity: O(V + E)
Example
Use Cases
val graph: obj
val options: bool
Multiple items
module Set from Microsoft.FSharp.Collections -------------------- type Set<'T (requires comparison)> = interface IReadOnlyCollection<'T> interface IStructuralEquatable interface IComparable interface IEnumerable interface IEnumerable<'T> interface ICollection<'T> new: elements: 'T seq -> Set<'T> member Add: value: 'T -> Set<'T> member Contains: value: 'T -> bool override Equals: objnull -> bool ... -------------------- new: elements: 'T seq -> Set<'T> val ofList: elements: 'T list -> Set<'T> (requires comparison)
val diagram: obj
|
||
|