Search code examples
graphviz

graphviz collapse parallel paths


Is it possible to collapse multiple paths like shown in the picture with graphviz? And if so any suggestions on how this could be achieved?

enter image description here


Solution

  • I'm used to the weeds.
    Comment out unwanted nodes and edges and add 3 nodes with shape=point. You might also create invisible edges to/from the new nodes, I did not. This:

    digraph ellipsis {
     rankdir=RL
     nodesep=.1
     node [shape=circle]
     {
       rank=same
       B1
       B2 
       B3 
       /* comment out unwanted nodes
       B4
       B5
       ...
       */
       e4  [shape=point]
       e5  [shape=point]
       e6  [shape=point]
       B99
       edge [style=invis]
       B1 ->  B2 ->  B3  -> e4 ->  e5 -> e6 ->  B99
     }
     C -> B1
     C -> B2 
     C -> B3 
     /* comment out unwanted edges
     C -> B4
     */
     C -> B99
    
     B1  -> A
     B2  -> A
     B3  -> A
     /* comment out more unwanted edges
     B4 -> A
     */
     B99 -> A
    }
    

    Produces this:
    enter image description here