Generateing Graphs

Topics: graph
Sep 18, 2008 at 12:04 PM
Edited Sep 18, 2008 at 12:22 PM
Hi, I'm just following the example in the document, but haven't got any luck.
Here is the code snippet.

var g = new AdjacencyGraph<int, TaggedEdge<int, string>>();
            int v1 = 1;
            int v2 = 2;
            int v3 = 1;
            int v4 = 2;

            //The edges (v1,v2) and (v2,v1) are created and added to the graph.
            var e1 = new TaggedEdge<int,string>(v1,v2, "hello");

            // v3, v4 are not added to the graph yet
            var e2 = new TaggedEdge<int,string>(v3,v4,"hello");
            var e3 = new TaggedEdge<int, string>(v1, v3, "v1->v3");

            GraphvizAlgorithm<int, TaggedEdge<int, string>> graphviz = new GraphvizAlgorithm<int, TaggedEdge<int, string>>(g, @"c:\", QuickGraph.Graphviz.Dot.GraphvizImageType.Png);

            // render
            string output = graphviz.Generate(new FileDotEngine(), "outputTest");

I didn't see any particular file generated, neither the exceptions, except that in the bin folder. And it's content is not what I expected either.
digraph G {
0 ;
1 ;
0 -> 1 [];
0 -> 1 [];

Is there anyone could help ? How do I generate an image by using the lib? Do I also need to install Graphviz?

Sep 18, 2008 at 6:11 PM
Yes, you need graphviz to render the .dot file to an image. Please refer to Graphviz documentation on how to do that.

To 'customize' the output of the dot file, hook to {{graphviz.FormatVertex}} event.