Package: effect
Module: Graph
Exports a graph to GraphViz DOT format for visualization.
Example
import { Graph } from "effect"
const graph = Graph.mutate(Graph.directed<string, number>(), (mutable) => {
const nodeA = Graph.addNode(mutable, "Node A")
const nodeB = Graph.addNode(mutable, "Node B")
const nodeC = Graph.addNode(mutable, "Node C")
Graph.addEdge(mutable, nodeA, nodeB, 1)
Graph.addEdge(mutable, nodeB, nodeC, 2)
Graph.addEdge(mutable, nodeC, nodeA, 3)
})
const dot = Graph.toGraphViz(graph)
console.log(dot)
// digraph G {
// "0" [label="Node A"];
// "1" [label="Node B"];
// "2" [label="Node C"];
// "0" -> "1" [label="1"];
// "1" -> "2" [label="2"];
// "2" -> "0" [label="3"];
// }
Signature
declare const toGraphViz: <N, E, T extends Kind = "directed">(graph: Graph<N, E, T> | MutableGraph<N, E, T>, options?: GraphVizOptions<N, E>) => string
Since v3.18.0