2

在提问之前,我试图搜索我的问题的答案,但我找不到。我的问题是关于改变点图中的边缘方向。Rankdir 是'LR',但在图表的某些部分,我想使用'TB'。让我举个例子。

有向图 G {
  等级目录=LR;
  尺寸=“7,5”;
  浏览器->ui_thread;
  浏览器->db_thread;
  浏览器->webkit_thread;
  浏览器->缓存线程;
  浏览器->file_thread;
  浏览器->io_thread;
  io_thread[样式=填充];
  缓存线程[样式=填充];
  ui_thread->线程[标签=继承];
  ui_thread->messageloop[style=dotted];
  db_thread->messageloop[style=dotted];
  webkit_thread->messageloop[style=dotted];
  cache_thread->messageloop[style=dotted];
  文件线程->消息循环[样式=点];
  io_thread->messageloop[style=dotted];
}

它给出了这样的图表 输出图

但是,这不是我想要的。我想要下图。“thread”垂直位于“ui_thread”上方。 在此处输入图像描述 您可能认为使用带有“thread”和“ui_thread”的“rankdir=same”可以轻松解决。我肯定已经试过了。但我失败了。“线程”始终低于“ui_thread”。

谢谢,

4

1 回答 1

3

不幸的是,图形方向只能指定一次,并且整个图形都保持在该方向。在这种情况下,您通常可以通过组合constraint=false和不可见的边缘来强制一些排序来获得所需的效果。

此代码将生成您的第二张图片:

digraph G {
  rankdir=LR;
  size="7,5";
  browser->thread[style=invis];
  browser->ui_thread;
  browser->db_thread;
  browser->webkit_thread;
  browser->cache_thread;
  browser->file_thread;
  browser->io_thread;  
  io_thread[style=filled];
  cache_thread[style=filled];
  ui_thread->thread[label=inherit constraint=false]; 
  ui_thread->messageloop[style=dotted];
  db_thread->messageloop[style=dotted];
  webkit_thread->messageloop[style=dotted];
  cache_thread->messageloop[style=dotted];
  file_thread->messageloop[style=dotted];
  io_thread->messageloop[style=dotted];
}
于 2011-05-28T17:42:34.690 回答