Discussion:
[graphviz-interest] layout control
George Georgalis
2011-06-28 20:10:32 UTC
Permalink
Hi All,

Graphviz has been a wonderful tool over the years, thanks all for your
development and support!

Today, I'd like to offer a question about layout. I seem to recall a
graph option about no overlap (?), but I was never able to use it to
prevent edges from crossing. The below graph source below is based on
http://www.ischool.utexas.edu/~wyllys/SAEMaterials/sysdevcycle.html
and is a perfect example. It's not too difficult to visualize a
resolution to edge overlap, but training graphviz to avoid it can be
tricky. Here I use rank and A->B->C elements to get a "better" layout
(I then crop the extra nodes or make them same color as background).

I was wondering if anyone can recommend a better approach to keep
edges from crossing?

Regards,
George


A -> B -> C
{rank=same A "OPERATION" };
{rank=same B "System\n Testing" };
{rank=same C "Operational\n Evaluation" };


"On-Going\n Evaluation"
-> { rank=same
"ANALYSIS"
-> "DESIGN"
-> "PRODUCTION"
-> "IMPLEMENTATION"
-> "OPERATION"
}

"IMPLEMENTATION"
-> "System\n Testing"
-> "PRODUCTION"

"OPERATION"
-> "Operational\n Evaluation"
-> {
"PRODUCTION"
"ANALYSIS"
}
_______________________________________________
graphviz-***@research.att.com
https://mailman.research.att.com/mailman/listinfo/graphviz-interest
Emden R. Gansner
2011-06-28 20:28:02 UTC
Permalink
The algorithm used by dot attempts to reduce edge crossings but this
is only done after the nodes are
put into ranks, which limits what the algorithm can accomplish. Thus,
a lot of ad hoc tweaking may
still be necessary.

One small simplification: in your graph, you want "Operational
Evaluation" on a different level from
"System Testing". In this case, you don't need the A->B->C chain but
can just set minlen=2 on
the edge OPERATION->"Operational Evaluation" .

The result is attached.

Emden
George Georgalis
2011-06-28 20:59:33 UTC
Permalink
Thanks, I've not made use of the minlen parameter before. It works nicely here.

What are you using for the straight edges?

Regards,
George
The algorithm used by dot attempts to reduce edge crossings but this is only
done after the nodes are
put into ranks, which limits what the algorithm can accomplish. Thus, a lot
of ad hoc tweaking may
still be necessary.
One small simplification: in your graph, you want "Operational Evaluation"
on a different level from
"System Testing". In this case, you don't need the A->B->C chain but can
just set minlen=2 on
the edge OPERATION->"Operational Evaluation" .
The result is attached.
   Emden
_______________________________________________
graphviz-***@research.att.com
https://mailman.research.att.com/mailman/listinfo/graphviz-interest
Emden R. Gansner
2011-06-28 21:02:11 UTC
Permalink
Post by George Georgalis
What are you using for the straight edges?
splines=ortho

Emden

_______________________________________________
graphviz-***@research.att.com
https://mailman.research.att.com/mailman/listinfo/graphviz-interest
George Georgalis
2016-08-10 18:44:11 UTC
Permalink
Belated thanks... that was useful, Emden.

I have a similar challenge today, I'd like to render concentric networks in
a gv, like the jpg attachment. The arrows pointing to the center are less
important, regardless, the rendering problem has been non-concentric loops,
and figure-eights where I expected circles.

A1 -> B1 -> C1 -> D1 -> A1
A2 -> B2 -> C2 -> D2 -> A2
A3 -> B3 -> C3 -> D3 -> A3
{rank=max A1 B1 C1 D1 }

A1 -> A2 -> A3 -> E1
B1 -> B2 -> B3 -> E1
C1 -> C2 -> C3 -> E1
D1 -> D2 -> D3 -> E1
{rank=min E1}

A neato rendering is also attached. If I remove the last 5 lines and use
circo, I can get circles, but they are not concentric. Anyone have a
suggestion for this graph?

-George
Post by Emden R. Gansner
Post by George Georgalis
What are you using for the straight edges?
splines=ortho
Emden
--
George Georgalis, (415) 894-2710, http://www.galis.org/
Emden R. Gansner
2016-08-15 14:18:57 UTC
Permalink
The simplest way to get the required node positions is to use

twopi -Groot=E1

If you want the radial arms horizontal and vertical, you would have to
do the rotation afterwards. Or you can remove the edges making the
circles (via gvpr) , and layout the graph with

neato -Gstart=self -Goverlap=false

You can also tweak in the input, replacing D3 -> E1 by the edge E1 -> D3
[dir=back] placed at the top if the input and add -Gnormalize.

gv doesn't support actual circular arcs; splines=curved might be
acceptable. So, with the input gg.gv:

digraph {
{ edge[on_circle=1]

A1 -> B1 -> C1 -> D1 -> A1
A2 -> B2 -> C2 -> D2 -> A2
A3 -> B3 -> C3 -> D3 -> A3
}

A1 -> A2 -> A3 -> E1
B1 -> B2 -> B3 -> E1
C1 -> C2 -> C3 -> E1
D1 -> D2 -> D3 -> E1
}

run

twopi -Groot=E1 gg.gv | gvpr -c 'E[on_circle]{$.pos = "" }' | neato -n2
-Gsplines=curved

If you really want circles, a hack I have used in the past is to use the
gvpr pass to add nodes with shape=circle,
positioned at E1 with the appropriate radius.
Post by George Georgalis
Belated thanks... that was useful, Emden.
I have a similar challenge today, I'd like to render concentric
networks in a gv, like the jpg attachment. The arrows pointing to the
center are less important, regardless, the rendering problem has been
non-concentric loops, and figure-eights where I expected circles.
A1 -> B1 -> C1 -> D1 -> A1
A2 -> B2 -> C2 -> D2 -> A2
A3 -> B3 -> C3 -> D3 -> A3
{rank=max A1 B1 C1 D1 }
A1 -> A2 -> A3 -> E1
B1 -> B2 -> B3 -> E1
C1 -> C2 -> C3 -> E1
D1 -> D2 -> D3 -> E1
{rank=min E1}
A neato rendering is also attached. If I remove the last 5 lines and
use circo, I can get circles, but they are not concentric. Anyone have
a suggestion for this graph?
-George
On Tue, Jun 28, 2011 at 2:02 PM, Emden R. Gansner
What are you using for the straight edges?
splines=ortho
Emden
--
George Georgalis, (415) 894-2710, http://www.galis.org/
_______________________________________________
http://lists.research.att.com/mailman/listinfo/graphviz-interest
George Georgalis
2016-08-23 18:04:47 UTC
Permalink
Thanks, the twopi -Groot=E1 was very helpful. Of course, the very first
change I wanted was to eliminate E1, but invisible works fine for that. (I
don't suppose there is an equivalent root function without a root node?)

My challenge is to graph alternate representations of a network, in both
hierarchical and matrix forms, while retaining the perception that it is
the same network. The (twopi) layout emphasizes inputs of higher scope,
while a matrix layout emphasizes peer (same scope) inputs.

A1 -> B1 -> C1 -> D1 -> A1t2 -> B1t2 -> C1t2 -> D1t2 -> A1t3 ...

The above is a time series, representing 2.25 cycles of the broadest scope
(a matrix row). I'm not very happy with the matrix representations. The
twopi graph works well, accept I would like to emphasize the concentric
inputs more, since that is the traditional barrier and the key point of the
illustration.
Post by Emden R. Gansner
The simplest way to get the required node positions is to use
twopi -Groot=E1
If you want the radial arms horizontal and vertical, you would have to do
the rotation afterwards. Or you can remove the edges making the circles
(via gvpr) , and layout the graph with
neato -Gstart=self -Goverlap=false
You can also tweak in the input, replacing D3 -> E1 by the edge E1 -> D3
[dir=back] placed at the top if the input and add -Gnormalize.
gv doesn't support actual circular arcs; splines=curved might be
digraph {
{ edge[on_circle=1]
A1 -> B1 -> C1 -> D1 -> A1
A2 -> B2 -> C2 -> D2 -> A2
A3 -> B3 -> C3 -> D3 -> A3
}
A1 -> A2 -> A3 -> E1
B1 -> B2 -> B3 -> E1
C1 -> C2 -> C3 -> E1
D1 -> D2 -> D3 -> E1
}
run
twopi -Groot=E1 gg.gv | gvpr -c 'E[on_circle]{$.pos = "" }' | neato -n2
-Gsplines=curved
If you really want circles, a hack I have used in the past is to use the
gvpr pass to add nodes with shape=circle,
positioned at E1 with the appropriate radius.
Belated thanks... that was useful, Emden.
I have a similar challenge today, I'd like to render concentric networks
in a gv, like the jpg attachment. The arrows pointing to the center are
less important, regardless, the rendering problem has been non-concentric
loops, and figure-eights where I expected circles.
A1 -> B1 -> C1 -> D1 -> A1
A2 -> B2 -> C2 -> D2 -> A2
A3 -> B3 -> C3 -> D3 -> A3
{rank=max A1 B1 C1 D1 }
A1 -> A2 -> A3 -> E1
B1 -> B2 -> B3 -> E1
C1 -> C2 -> C3 -> E1
D1 -> D2 -> D3 -> E1
{rank=min E1}
A neato rendering is also attached. If I remove the last 5 lines and use
circo, I can get circles, but they are not concentric. Anyone have a
suggestion for this graph?
-George
Post by Emden R. Gansner
Post by George Georgalis
What are you using for the straight edges?
splines=ortho
Emden
--
George Georgalis, (415) 894-2710, <http://www.galis.org/>
http://www.galis.org/
_______________________________________________
http://lists.research.att.com/mailman/listinfo/graphviz-interest
--
George Georgalis, (415) 894-2710, http://www.galis.org/
Continue reading on narkive:
Loading...