Output an image of a directed acyclic graph
-
27-10-2019 - |
Question
I'd like to:
- Represent a DAG according to The Ruby Way.
- Generate an image from the DAG.
There would be no more than 100 nodes (and often far less, say, 10 for the 80th percentile case). I do not need to permanently store the data, just the image, so no database considerations need to be made.
Solution
Graphviz is the tried-and-true tool for visualizing all sorts of graphs, and it's been around for a while. See: http://www.graphviz.org/
There's Ruby wrapper around it available, see: https://github.com/glejeune/Ruby-Graphviz
(disclaimer: I've used Graphviz, but not the Ruby wrapper)
OTHER TIPS
If all you need to do is output images, I'd feed textual representations into the "dot" tool of graphviz.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow