1

I am able to generate graph files using graphviz (dot.exe) through command line. Need to generate graph using Quickgraph.Graphviz without installation. Is it possible?

Praveena M
  • 522
  • 4
  • 10

1 Answers1

2

It depends a little how you define "installation". If you wish to use the dot.exe that is currently on your system from code you can (from an example I can't refind online):

public sealed class GraphRenderer : IDotEngine
{
    public string Run(GraphvizImageType imageType, string dot, string outputFileName)
    {
        string output = outputFileName;
        File.WriteAllText(output, dot);

        // assumes dot.exe is in the path EnvVar:
        var args = $@"{output} -Tjpg -O";
        System.Diagnostics.Process.Start("dot", args);
        return output;
    }
}

Used:

var exportGraph = new GraphvizAlgorithm<TNode, TEdge>(graphToDraw);
exportGraph.Generate(new GraphRenderer(), "ActionGraph");

And you can modify the rendering with exportGraph.FormatVertex/FormatEdge. Although here I assume "dot" is in the Environment Variables, if this is too installed, there's no reason you can't point the process to a local file.

Seb Andraos
  • 357
  • 3
  • 15