Search code examples
graphvizdot

Graphviz dot - possible to mix edge types on the same digraph?


As far as I can see in this example: How to prevent Graphviz from moving nodes to accomodate an edge - Help - Graphviz - splines=polyline; is an attribute of a graph as a whole: it says in splines | Graphviz that it is "Valid on: Graphs".

And, as far as I can see, there is nothing similar to splines in Edge Attributes | Graphviz.

So, quite probably, it is not possible to mix two types of edges (polyline and spline) in the same digraph -- but I'd still like to make finally sure: for instance, due to being "Valid on: Graphs" - would splines maybe be also valid on subgraphs? If so, then maybe one could use subgraphs, to group edges that should be styled as, say, polyline (or spline - btw, I tried this, did not work for me).

In any case, is there any way, to choose a subset of edges on a Graphviz dot diagram, and have it rendered with a different splines setting (say, polyline), from the setting of the parent/container digraph (say, spline)? (if not, an explicit answer would be much appreciated).


Solution

  • Yes, the splines attribute is a (Root) graph-level attribute. (all or nothing). There are no edge-level overrides. (though that would be nice).

    However, there are several ways to combine multiple spline type, but not in one invocation of dot (or any of the layout engines) (see below)

    The first question should be "Is this really necessary?"

    • Sometimes it is. Here is an example of combining spline types that the user really wanted: Graphs with mixed splines OR merge layers with different splines. Note that the answer describes two ways of accomplishing your goal.
    • Sometimes not fully necessary, but just a user (like me) throwing hands in the air and giving up. (Been there, done that). Polyline frequently gives "mixed" results - but same is true of all the other spline options.
      Anyway, if this is a one-time need, the answers above should suffice, but if is to be used may times and/or automated, that can be accomplished also. Graphviz has some poorly documented capabilities to "mark" objects (edges in this case) so they can be pre or post processed and then revisited (edge pos values erased and then reworked by a n-th engine invocation)