Search code examples
boost-graph

Drawing a graph with some properties displayed with Boost Graph Library


everyone. I have been using Boost Graph Library but it's quite difficult to me. Recently, I have tried to draw the following graph (I used .dot file to display coz I don;t have enough reputation to attach a picture, sorry for any inconvenience caused)

enter code here
graph{
    0[label = "Prof Nachiket", color = blue];
    1[label = "Nick", color = red];
    2[label = "Lam", color = green];
    0 -- 1[label = "Supervisor"];
    0 -- 1[label = "Supervisor"];
    1 -- 2[label = "Co-worker" ];

}

And then turn it into a picture with Graphviz. However, I got no idea how to add information such as label, color into edges of graph. In other words, I have a little or no idea how to draw above graph by using Boost Graph Library. Could anyone help me out? Thanks a lot

Best Regards

Nick Ng


Solution

  • NEW ANSWER

    Its a dube, see

    OLD ANSWER:

    There are many resources online which specifies how to draw advanced graphs using Graphviz. Here are some which I have found useful in the past:

    • www.graphviz.org/pdf/dotguide.pdf‎
    • www.graphviz.org/content/attrs
    • www.graphviz.org/content/output-formats
    • www.graphviz.org/doc/info/shapes.html
    • http://graphviz-dev.appspot.com/

    The last link is an online render, very useful if you dont have graphviz on your machine. For your specific question here's a simple example using colored edges and labels:

    Dot:

    graph{
        0 [label = "Prof Nachiket", color=blue shape=ellipse ];
        1 [label = "Nick", color = red shape=Mdiamond];
        2 [label = "Lam", color = green shape=diamond];
        0 -- 1[label = "Supervisor" color=pink];
        1 -- 2[label = "Co-worker" color=red penwidth=2];
    }
    

    Img:

    Image generated from above dot code