简体   繁体   English

graphviz中的正交边布局

[英]Orthogonal edges layout in graphviz

I'm traying to use graphviz to generate orthogonal graphs:我正在尝试使用 graphviz 生成正交图:

graph G {
    layout=neato
    splines=ortho

    A1 [ pos="1,1!" ]
    A2 [ pos="2,1!" ]
    A3 [ pos="3,1!" ]
    A4 [ pos="4,1!" ]
    Ae [ pos="5,1!" style=invis]

    B1 [ pos="6,6!" ]
    B2 [ pos="6,5!" ]
    B3 [ pos="6,4!" ]
    B4 [ pos="6,3!" ]

    C1 [ pos="1,8!" ]
    C2 [ pos="2,8!" ]
    C3 [ pos="3,8!" ]
    C4 [ pos="4,8!" ]

    A1 -- C1
    A2 -- C2
    A3 -- B3
    A4 -- B4
    C3 -- B2
    C4 -- B1
}

which produces following: orthogonal graph产生以下:正交图

My questions are:我的问题是:

  1. Is it possible to generate similar layout whithout neato and hardcoded node positions?是否可以在没有neato和硬编码节点位置的情况下生成类似的布局?

  2. How to force edges connected to A3, A4, C3, C4 to be so perfectly aligned to the middle of node as in the cases of A1, A2, C1, C2, B1-4 ?在 A1、A2、C1、C2、B1-4 的情况下,如何强制连接到 A3、A4、C3、C4 的边与节点的中间如此完美对齐?

  3. How to surround A1-4, C1-4, B1-4 into three boxes without changing the layout?如何在不改变布局的情况下将A1-4、C1-4、B1-4围成三个盒子? (I've tried subgraph clusters but they seem to be not supported by the neato layout; HTML Tables are the option however they seem to be not so perfect in line joining to the cells - ports) (我已经尝试过子图集群,但它们似乎不受neato布局的支持;HTML表格是选项,但它们似乎不太完美地连接到单元格 - 端口)

  4. Is it possible to remove the invisible "Ae" node and save the present layout?是否可以删除不可见的“Ae”节点并保存当前布局? (when I just remove "Ae" some edges change their layout...) (当我刚刚删除“Ae”时,一些边缘会改变它们的布局......)

for 1.) no 对于1.)否
for 2.) just use pos 对于2.)只需使用pos
for 3.) Please show your tries, so we can perhaps elaborate on this. 3)请显示您的尝试,以便我们可以对此进行详细说明。
for 4.) no 对于4.)否

Perhaps you try to use graphviz like an UML-Modelling- or Visio-Tool. 也许您尝试使用诸如UML建模工具或Visio工具之类的graphviz。 In the core graphviz is more for creating the layout as an output, less for consuming layout information as input. 在核心中,graphviz更多地用于将布局创建为输出,而不是将布局信息作为输入使用。

First, it seems that there are not pos attribute for edge in neato engine or other engines.首先,在neato引擎或其他引擎中似乎没有边缘的pos属性。 I follow this answer to solve this question.我按照这个答案来解决这个问题。 using a point shape with (width attribute 0) to control the edge.使用具有(宽度属性 0)的点形状来控制边缘。

a code example as follow:代码示例如下:

digraph {
    graph [bgcolor=white size="5.0,6.66!"]
    node [fixedsize=true]
    P1 [label=hello fontname=FangSong pos="2.604,4.583!" shape=rect]
    P0 [label=graphviz fontname=FangSong pos="0.521,5.625!" shape=rect]
    point1 [label="" fontname=FangSong pos="1.562,5.625!" shape=point width=0]
    point2 [label="" fontname=FangSong pos="1.562,4.583!" shape=point width=0]
    P0 -> point1 [arrowhead=none]
    point1 -> point2 [arrowhead=none]
    point2 -> P1 [arrowhead=normal]
}

the figure is :数字是:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM