Search code examples
c++boostgraphvizgraph-visualization

Is there a function in boost library to generate directly the png file instead of dot?


I am writing a C++ program which generates a tree with graphviz. I am producing the dot file but I would like to produce the png file directly in my script without using terminal or system(command).

Is there a function in boost which can do this? It would be something like

write_png(Graph g, string filename)

Solution

  • Well, no. Boost has:

    • A facility for reading Graphviz (.dot) files, as part of Boost Graph Library.
    • The GIL - Generic Image Library - Which lets you read and write Portable Network Graphics (.png) files.

    but the former produces the structure of a graph, while the latter requires a raster image, not some structured representation. The rendering of a .dot file into a vector or raster image is what the GraphViz library is about, and you would need to use it directly. I'd look at at what the sources of the dot utility do, and basically reproduce the relevant parts into your own source.