Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rank attribute is confusing to me

Tags:

graphviz

dot

Rank attribute on edge has five values "same", "min", "source", "max", "sink". Except "same", I have no idea when to use other values.

min \begin{dotpic}   rankdir=LR;   size="7,5";   node[shape=circle];   C->A;   {rank=min;A;B}   B->D   A->B; \end{dotpic}  max \begin{dotpic}   rankdir=LR;   size="7,5";   node[shape=circle];   C->A;   {rank=max;A;B}   B->D   A->B; \end{dotpic}  source \begin{dotpic}   rankdir=LR;   size="7,5";   node[shape=circle];   C->A;   {rank=source;A;B}   B->D   A->B; \end{dotpic}  sink \begin{dotpic}   rankdir=LR;   size="7,5";   node[shape=circle];   C->A;   {rank=sink;A;B}   B->D   A->B; \end{dotpic} 

With test on my vim environment, I can realize there is some difference btw these values. But don't know exactly what they are for.

like image 478
nirvana9235 Avatar asked May 27 '11 08:05

nirvana9235


1 Answers

Leaving the rank empty or using rank=same are used far more often. These other four are usually only used in special circumstances.

When used alone, min and source have the same function: putting all those nodes on the minimum rank (the top row of a TB graph). The difference between them is that min will allow other subgraphs in the minimum rank. Source will not. Source only allows other subgraphs of min or source to be on the minimum rank.

Consider the following graph snippet:

{ rank=source; a -> b; } { rank=same;   c -> d; } 

You will end up with 2 rows. a -> b will be above c -> d.

Source


If you change source to min, you will only get one row. a -> b will be to left of c -> d, all in the min rank.

{ rank=min;    a -> b; } { rank=same;   c -> d; } 

Min

Max and sink are the equivalents for the bottom of the graph.

like image 95
Dan Avatar answered Sep 23 '22 23:09

Dan