Skip to main content David Edelstein's Blog

🦙
🦙

Using Graphviz Wrapper from LinqPad

Published: 2015-06-25
dave@edelsteinautomotive.com
David Edelstein

Install Graphviz for Windows and clone the git repository for the wrapper

Then, build the wrapper project.

In a new LinqPad query add the output of the build. And set the import namespaces to:

GraphVizWrapper
GraphVizWrapper.Commands
GraphVizWrapper.Queries

After all that is setup, you can now run this sample code from LinqPad:

var getStartProcessQuery = new GetStartProcessQuery();
var getProcessStartInfoQuery = new GetProcessStartInfoQuery();
var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery);

var wrapper = new GraphGeneration(getStartProcessQuery,
                               getProcessStartInfoQuery,
                               registerLayoutPluginCommand);

wrapper.GraphvizPath = @"C:Program Files (x86)Graphviz2.38in";
wrapper.RenderingEngine = Enums.RenderingEngine.Dot;

var output = wrapper.GenerateGraph(
  @"digraph{a -> b; b -> c; c -> a;}", 
  Enums.GraphReturnType.Png);
Util.RawHtml(
  String.Format(
    "<img src="data:image/jpg;base64,{0}" />", 
    Convert.ToBase64String(output))).Dump();