2

Is there a way to group edges together into a single bus in DOT/Graphviz, while still fraying the edges near nodes?

Eg:

Changing this:

graph my_graph {
    rankdir=LR
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- C;
}

enter image description here

into something like this:

example bus

1 Answer 1

2

One way to do it is with dummy [shape=point] nodes, like so:

graph my_graph {
    rankdir=LR;
    {rank = same; B; C;}
    aa [ shape=point ];
    bb [ shape=point ];
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;
    A -- aa;

    aa -- bb [ penwidth=4.0];

    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;
    bb -- B;

    A -- C;
}

with dummy point nodes

This has some downsides though:

  1. it doubles the number of edges in your source file, and makes it hard to manage.
  2. If you have head and tail labels, then you need to place them accordingly.
  3. It mucks up your node ranks, so you have to manually adjust all the other nodes.
  4. The frayed ends are still rounded and taking up a lot of space. This might be fixable by setting the splines attribute, but I haven't been able to get it to work (it seems like no multiple edges between two nodes are always shown as splines no matter what the value of splines is).

Another option:

There's also the concentrate attribute, but this will only collect lines going to the same point. It will not 1) fray ends or 2) increase line thickness to represent the bus:

graph my_graph {
    rankdir=LR
    concentrate=true;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- B;
    A -- C;
}

using concentrate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.