Vertices with String Names

Topics: graph
Sep 20, 2010 at 5:42 PM

Folks,

This should be a simple question for this crew.  I am trying to generate a graph with the code below.  However, the vertices are labled ordinally, instead of with the string value I provide.  I would like to see the vertices below labeled as "root", "intermediate", and "hola" instead of "0", "1", "2".  How do I change this?  I tried playing with some of the formatting members but to no avail.


Thanks for your help,


Chris       

//create a new graph
        var g = new AdjacencyGraph<string, TaggedEdge<string, string>>();
        var graphviz = new QuickGraph.Graphviz.GraphvizAlgorithm<string, TaggedEdge<string, string>>(g);
        //create vertexes
        string v1 = "root";
        string v2 = "intermediate";

        g.AddVertex(v1);
        g.AddVertex(v2);
        g.AddVertex("hola");
        var e1 = new TaggedEdge<string,string>(v1,v2,"hello");
        g.AddEdge(e1);
           
        //Render Graph
        graphviz.CommonVertexFormat.FontColor = System.Drawing.Color.FromName("Green");
        
        string output = graphviz.Generate(new FileDotEngine(), "c:\\graphoutput\\graph");

Sep 28, 2010 at 1:57 PM

Hello, in order to make this you should implément the event FormatVertex or FormatEdge on graphviz object.

It permit to customize the label,comment,color set to the edge and the vertex in dot file.