Search code examples
graphvizdotedges

Add extra edges to a digraph in Graphviz


I have a .dot digraph which shows a graph as I want (depicting relationship between some tables). I want to add redundant edges to the graph (to represent redundant relationships in the database which exist only to write queries less effortly). These redundat edges, which will be written in a "dotted" style, must not change the deployment of nodes in the graph.

In other words, there's edges which must affect the node positions to print the graph pretty, and other edges which must to be added after the node positions are already computed (which will be styled differently --light gray, dotted, etc; to show that they're not main edges).

Is there options in Graphviz to specify "extra" edges?


Solution

  • Use constraint=false and color=gray on those additional edges.

    digraph G {
        a -> b -> c -> d;
        d -> a [constraint=false,color=gray]
        a -> z -> x -> d;
    }
    

    enter image description here

    Play with that on http://graphviz.it/#/rhlWBZsz