2

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...)

aoi
  • 21
  • 3

2 Answers2

1

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

J.Zhao
  • 2,250
  • 1
  • 14
  • 12
-1

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.

CodeFreezr
  • 362
  • 2
  • 18
  • Thank you for your answer. Let me ask about (2) - I've checked the [neato guide](http://www.graphviz.org/pdf/neatoguide.pdf) doesn't contain any example of use `pos` for edges. So how can I use it? Generally, I'm open for any open-source tool allowing for its automation. For example, the solution I considered was the "direct" SVG generation. However I had hoped to find something faster in the meaning of graph shape prototyping - SVG requires manual calcultaions. Now I see also the graphviz has such needs. – aoi Mar 13 '18 at 11:15
  • You can use for example an edge [shape=point] and voilá you have an anchor for real pos-coordinates. I have uncovers the mighty pos attributes just some days ago, see: [tweet-about coordinates in graphviz](https://twitter.com/DetlefBurkhardt/status/971903115489398784). The most important beahviour you have to incoporate is, that zero is just in the center of your graph. – CodeFreezr Mar 13 '18 at 22:12
  • I understand the usage of `pos` attribute for neato nodes, but I never heard about its usage for graphviz eges. Would you like to elaborate a bit more about your idea? – aoi Mar 15 '18 at 16:44