Rank attribute is confusing to me

杀马特。学长 韩版系。学妹 提交于 2020-01-11 19:56:26

问题


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.


回答1:


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.


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; }

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



来源:https://stackoverflow.com/questions/6149834/rank-attribute-is-confusing-to-me

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!