如何在GraphViz中设置基于记录的节点的端口的样式? [英] How do I style the ports of record based nodes in GraphViz?

查看:102
本文介绍了如何在GraphViz中设置基于记录的节点的端口的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在提供这个简单的输入脚本,该脚本定义了基于记录的节点点以从中创建SVG(SVG部分实际上无关紧要):

I'm feeding this simple input script defining record based nodes to dot in order to create a SVG from it (the SVG part actually doesn't matter):

graph mygraph{
  node [shape=record, fontsize=10, fontname=Arial];
  rankdir=TB;
  ranksep=0.5;
  rank=max;
  splines=true;
  overlap=false;
  mindist=0.2;
  "d1" [style=solid, label="{\N|{<0> 0|<1> 1}}"];
  "d2" [style=solid, label="{\N|{<0> 0|<1> 1|<2> 2|<3> 3}}"];
  "d1":0 -- "d2":0[color=blue, penwidth=3, tooltip="d1:0 -- d2:0", URL="#"];
}

这将产生一个图形,其中d1的端口0和d2的端口0通过蓝色样条线连接:

This yields a graph where ports 0 of d1 and port 0 of d2 are connected by a blue spline:

好.

现在,我需要为端口着色.例如:d2的端口1应该是绿色,而d2的端口2应该是橙色.等等.

Now I have the need to colorize the ports. For example: port 1 of d2 shall be green and port 2 of d2 shall be orange. Or something.

我该如何实现?

节点周围的实心框架很重要.对于某些节点,我需要牢固,对于其他节点,则需要虚线.

Edit 1: the solid frame around the nodes is important. I need it solid for some nodes, dashed for others.

推荐答案

类似于HTML的标签使您在设置标签格式时具有很大的灵活性.这段代码:

HTML-like labels give you a lot of flexibility in formatting labels. This code:

graph mygraph{
  node [shape=record, fontsize=10, fontname=Arial];
  rankdir=TB;
  ranksep=0.5;
  rank=max;
  splines=true;
  overlap=false;
  mindist=0.2;
  d1 [shape=none, margin=0, label=<
    <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
        <tr><td colspan="2">d1</td></tr>
        <tr><td port="0">0</td><td>1</td></tr>
    </table>>];
  d2 [shape=none, margin=0, label=<
    <table border="0" cellborder="1" cellspacing="0" cellpadding="4">
        <tr><td colspan="4">d2</td></tr>
        <tr><td port="0">0</td><td bgcolor="green">1</td><td bgcolor="orange">2</td><td>3</td></tr>
    </table>>];
  d1:0 -- d2:0[color=blue, penwidth=3, tooltip="d1:0 -- d2:0", URL="#"];
}

产生此图:

请注意使用port属性来标识端口.

Note the use of the port attribute to identify the port.

这篇关于如何在GraphViz中设置基于记录的节点的端口的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆