I have a directed graph specified in Graphviz's dot
language, e.g.
digraph G { A -> B [label="foo"]; A -> B [label="bar"]; B -> A; C; }
I want to automatically process this into a graph with its edges reversed, i.e.
digraph G { B -> A [label="foo"]; B -> A [label="bar"]; A -> B; C; }
I would like to use a robust solution (i.e. one that understands the graph and therefore probably doesn't use sed
) that preserves any existing edge labels and other attributes. Note that I am not merely talking about getting dot
to render my graph with the arrows pointing backward; I really need a graph whose edges are reversed. (In this case, I intend to reverse the edges, apply prune
, then reverse the edges again.)
How can I reverse the direction of every edge in a Graphviz (dot
-language) graph?
edge [dir="back"];
– Bowerbird