record nodes and rankdir in graphviz

旧巷老猫 提交于 2020-01-21 04:19:05

问题


When I changed the rankdir of my graph from LR to TD, my record nodes also changed their layout direction so they no longer look like a 'record'. I tried applying a separate rankdir to the nodes, but this had no effect.

How does one keep the record nodes with the correct layout?

digraph sample { 
  graph [rankdir=TD];
  node [shape=record];

  A [label="ShouldBeTop | ShouldBeBottom"];
  B [label="Top | Bottom"];
  A -> B;
}

回答1:


Taking into account that rankdir effectively replaces the notion of "top" and "bottom" for the given graph, that's not surprising.

I am afraid that there is no easy remedy for this, save hacking the source (and that would not be easy at all). You can surround your labels in "{}" with some kind of mass search-replace solution to get the requested effect:

digraph sample { graph [rankdir=TD]; node [shape=record];

A [label="{ShouldBeTop | ShouldBeBottom}"]; 
B [label="{Top | Bottom}"]; A -> B; 
}



回答2:


You can use html table like labels instead of records. IIRC the table based labels do not rotate with the rank direction. See http://www.graphviz.org/doc/info/shapes.html#html



来源:https://stackoverflow.com/questions/259415/record-nodes-and-rankdir-in-graphviz

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