从Graphviz中记录元素的中心开始绘制出边 [英] Drawing outgoing edges starting from the center of record elements in Graphviz

查看:117
本文介绍了从Graphviz中记录元素的中心开始绘制出边的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Graphviz中,是否可以从子记录的中心而不是边界开始画出子记录的出边?

In Graphviz, is it possible to draw the outgoing edges from sub-records starting from their centers instead of their borders?

此图 (原始文章)看起来确实如此,但是示例代码是错误的,我从清单1(绘制了,但是我在Graphviz 2.29中使用了twopi,结果是不同的(边缘从记录边界开始).

This diagram (original article) makes it seem so, but the example code is wrong and I tested the code from Listing 1 (draws this, but I used twopi instead) in Graphviz 2.29 and the outcome is different (edges start at the record borders).

有什么想法吗?

谢谢.

推荐答案

链接的文章来自2004年,此后对graphviz进行了一些更改.

The linked article is from 2004, some changed were made to graphviz since then.

在这里,如何适应列表°1会显示源自记录形状单元格中心的边缘:

Here's how to adapt listing °1 do display edges originating from the center of record shape cells:

在定义边缘之前添加以下行:

Add the following line before defining the edges:

edge[headclip=false, tailclip=false];

这告诉graphviz将边缘绘制到末端,而不是在边界节点处修剪边缘.

This tells graphviz to draw the edges to the end instead of clipping them at the border's node.

但是在这种情况下,这还不够,因为边缘已经使用了端口-我们可以添加 罗盘点 指示将边的末端/起点放置在何处.例如,为了使第一个边缘从J的中心到E的边界:

But this is not enough in this case because the edges use already a port - we can add a compass point to indicated where to place the end/beginning of the edge. For example, in order to have the first edge going from the center of J to the border of E:

        "node0":f1:c -> "node1":f1;

或者只是省略端口和罗盘点以使用节点的中心:

Or just leave out the port and compass point to use the center of the node:

        "node0" -> "node1":f1;


为了使所有边起源并在记录节点的中心终止:


In order to have all edges originate and end in the center of the record nodes:

digraph G
{
    node [shape = record];
    edge[headclip=false, tailclip=false];

    node0 [ label ="<f0> | <f1> J | <f2> "];
    node1 [ label ="<f0> | <f1> E | <f2> "];
    node4 [ label ="<f0> | <f1> C | <f2> "];
    node6 [ label ="<f0> | <f1> I | <f2> "];
    node2 [ label ="<f0> | <f1> U | <f2> "];
    node5 [ label ="<f0> | <f1> N | <f2> "];
    node9 [ label ="<f0> | <f1> Y | <f2> "];
    node8 [ label ="<f0> | <f1> W | <f2> "];
    node10 [ label ="<f0> | <f1> Z | <f2> "];
    node7 [ label ="<f0> | <f1> A | <f2> "];
    node3 [ label ="<f0> | <f1> G | <f2> "];

    // identical result: "node0" -> "node1";
    "node0":f1:c -> "node1":f1:c;
    "node0":f1:c -> "node2":f1:c;

    "node1":f1:c -> "node4":f1:c;
    "node1":f1:c -> "node6":f1:c;
    "node4":f1:c -> "node7":f1:c;
    "node4":f1:c -> "node3":f1:c;

    "node2":f1:c -> "node5":f1:c;
    "node2":f1:c -> "node9":f1:c;

    "node9":f1:c -> "node8":f1:c;
    "node9":f1:c -> "node10":f1:c;
}

这篇关于从Graphviz中记录元素的中心开始绘制出边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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