jason
jason

Reputation: 4449

graphviz: making node ranks exclusive

Here is a simple example from Graphviz: make edges not affecting the hierarchy of nodes.

digraph G {
    a -> b
    a -> c
    c -> d
    c -> e
    a -> f
    c -> f
    { rank=same; c f }
}

The answer has b,c,f all in the same rank even though it only specified { rank=same; c f }

My question is: is there a way to let the rank be only c and f?

I'm having problems when I specify {rank=same;989;988;952;953;950;951;} but other nodes show up in the same rank. Any tricks to make the rank exclusive some how?

Upvotes: 1

Views: 278

Answers (1)

Dany
Dany

Reputation: 4730

I think it's impossible to make rank exclusive but you can kick out unwanted nodes from the rank manually.

The Dot rule is that when you are connecting two nodes with an edge, the head node will usually increase its rank (unless its position is affected by other edges).

So what you may do in your situation: connect the unwanted node to one of the nodes in your "exclusive" rank and make this edge invisible:

digraph G {
    a -> b
    a -> c
    c -> d
    c -> e
    a -> f
    c -> f
    { rank=same; c f }
    b -> c [style=invis]
}

Result:

enter image description here

Upvotes: 2

Related Questions