Shields.GraphViz is a .NET wrapper for GraphViz. Easily enhance your applications with graph visualizations.
NuGet package ID: Shields.GraphViz
First define a graph.
Graph graph = Graph.Undirected
.Add(EdgeStatement.For("a", "b"))
.Add(EdgeStatement.For("a", "c"));Then render the graph to a stream.
IRenderer renderer = new Renderer(graphVizBin);
using (Stream file = File.Create("graph.png"))
{
await renderer.RunAsync(
graph, file,
RendererLayouts.Dot,
RendererFormats.Png,
CancellationToken.None);
}The location of your GraphViz installation, which is typically something like
C:\Program Files\Graphviz\bin, should be supplied as the value ofgraphVizBin.
The output graph.png follows.
- Fluent API for defining graphs
- Immutable graphs
- Asynchronous renderer
IRendererinterface for easy dependency injection and mocking
