13

I have C++ program using boost graph library. I wonder if there is any way to visualize the graph (nodes and optionally edges) following a certain position values contained in nodes. Please look the examples of the image bellow to understand what I want to visualise: http://img11.hostingpics.net/pics/647608graphViz.png

Thanks.

sehe
  • 374,641
  • 47
  • 450
  • 633
shn
  • 5,116
  • 9
  • 34
  • 62

1 Answers1

22

You're in luck.

Boost graph can serialize to and deserialize from the dot language (which is the language used by GraphViz). There are several examples in the (free) Boost Graph Library book and on the site.

See e.g.: http://www.boost.org/doc/libs/release/libs/graph/doc/write-graphviz.html

If you take the output of the sample on the previous webpage and run

dot -Tpng dot > test.png

You'll get something like the following picture:

enter image description here

Here is a direct link to an example using dynamic properties

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
sehe
  • 374,641
  • 47
  • 450
  • 633
  • 1
    That's awesome, thanks for you answer, I'll wee that. But is it possible to visualise a graph using edges and vertices of type setS (not vecS) ? Because I see that in all examples of graphviz the graph use vecS (which have an index). – shn Oct 28 '11 at 15:35
  • Since my graph use setS for vertex, I have to either provide a vertex_index property map for my graph, or give an explicit vertex_id argument to write_graphviz, otherwise write_graphviz will not work. Can you give me a very simple example of how to provide a vertex_index property map for my graph, or give an explicit vertex_id argument to write_graphviz ? My graph is defined as: typedef adjacency_list Graph; Where NodeData and EdgeData are structures. – shn Oct 28 '11 at 22:05