1
votes

I'm traying to use graphviz to generate orthogonal graphs:

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?

  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 ?

  3. How to surround A1-4, C1-4, B1-4 into three boxes without changing the layout? (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)

  4. Is it possible to remove the invisible "Ae" node and save the present layout? (when I just remove "Ae" some edges change their layout...)

2

2 Answers

0
votes

for 1.) no
for 2.) just use pos
for 3.) Please show your tries, so we can perhaps elaborate on this.
for 4.) no

Perhaps you try to use graphviz like an UML-Modelling- or Visio-Tool. In the core graphviz is more for creating the layout as an output, less for consuming layout information as input.

0
votes

First, it seems that there are not pos attribute for edge in neato engine or other engines. I follow this answer to solve this question. using a point shape with (width attribute 0) to control the edge.

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 :

enter image description here