Easy way to get text Dot input from a Graph

Jun 25, 2015 at 8:30 PM
Hi,

If I have a graph defined in my program, is there any easy way to get the plain text dot input out as a string?
I understand it would just be a description of vertexes and edges. I want to get something out like:
graph graphName {
a--b;
c--d;
}
Thanks
Coordinator
Jun 26, 2015 at 12:05 PM
Hello teldridge,

you can use GraphToDotConverter class, it has method Convert, which takes TextWriter instance, you can use StringWriter to get the DOT representation in string. For more details, take a look at the API documentation of the Convert method and how it is used in LayoutDirector.RunDot method.

Hope this helps,
Steve
Nov 27, 2016 at 12:04 PM
If I understand the question, I added some trace code to the RunDot() method:
            process.StartInfo = new ProcessStartInfo
                                    {
                                        CreateNoWindow = true,
                                        UseShellExecute = false,
                                        Arguments = "-Tdot",
                                        FileName = Path.Combine(this.DotExecutablePath, this.DotExecutable),
                                        RedirectStandardOutput = true,
                                        RedirectStandardInput = true
                                    };
            process.Start();
            process.StandardInput.AutoFlush = true;
            using (StreamWriter writer = File.CreateText(@"c:\temp\" + DateTime.Now.Ticks.ToString() + ".gv"))
            {
                writeGraph(writer);
                writer.Flush();
                writer.Close();
            }
            writeGraph(process.StandardInput);
            process.StandardInput.Close();
            return process.StandardOutput;
Best regards,
Michael Herman (Toronto)
Nov 27, 2016 at 12:28 PM
There's also an existing LogGraphvizOutput field that can be turned on in the XAML. Checkout https://graphviz4net.codeplex.com/workitem/10

Best regards,
Michael Herman (Toronto)