1

I have been trying to make a tree chart that has multiples sets of edges running between the nodes. The goal is to look something like this: Double edges

I can eaisly make a chart with one set of edges like so: Single Edges However, I cannot get figure out how to add the second set of edges without the edges going all over the place.

When I try to do this, my output looks something like this: My Ugly Output

I am not sure how to do this. My assumption is that graphviz is trying to avoid allowing edges to overlap.

My question is thus:

How can I make a display in graphviz that looks like the first of the three images, as opposed to the last of the three images.

The code I used to generate my graph is:

graph test_chart{
splines=ortho
rankdir=UD
ratio="fill"
graph[nodesep=1]
A[shape=box color=red, labe="A"group=1]
B[shape=box color=blue, label="B"]
C[shape=box color=blue, label="C" ]
D[shape=box color=blue label="D" ]
E[shape=box color=blue label="E"]
F[shape=box color=blue label="F"]
{p0, p1, p2, n0, n1, n2[shape=point label=""]}
p0[group=1]
edge[color="red"]
A-- p0

p1--B
p1--C
p2--D
p2--E

rank=same{p1--p0--p2}
{rank=same B--C--D--E[style=invis]}

edge[color=blue]
A-- n0
rank=same{n1--n0--n2}
n1--C
n1--D
n2--E
n2--F
}
BarrowWight
  • 181
  • 2
  • 12

2 Answers2

0

Yes, it can be done, barely, but I could only do it with a lot of futzing around. But I had to drop the orthogonal edges and use straight lines.

  1. Somehow, create an input file that gets the nodes placed where you want them.
  2. Run the command dot/fdp/neato -Tdot >work.dot This creates an augmented, but valid input file
  3. Edit work.dot to add intermediate (point) nodes and replace any original edges as necessary.
  4. Run the command neato -n -Tsvg/png/... to produce the desired uotput.

The graphviz FAQ talks about neato -n
All-in-all I'd suggest using the PIC language. It is more to the point.

graph test_chart {
    graph [bb="0,0,578,147.6",
        nodesep=1,
        splines=line
    ];
    node [label="\N",
        shape=point
    ];
    {
        graph [rank=min];
        node [label="",
            shape=point
        ];

        A    [color=red,
            height=0.5,
            label=A,
            pos="226,129.6",
            shape=box,
            width=0.75];
    }
    {
        graph [rank=max];
        node [shape=box];
        B    [color=blue,
            height=0.5,
            label=B,
            pos="27,18",
            shape=box,
            width=0.75];
        C    [color=blue,
            height=0.5,
            label=C,
            pos="153,18",
            shape=box,
            width=0.75];
        D    [color=blue,
            height=0.5,
            label=D,
            pos="299,18",
            shape=box,
            width=0.75];
        E    [color=blue,
            height=0.5,
            label=E,
            pos="425,18",
            shape=box,
            width=0.75];
        F    [color=blue,
            height=0.5,
            label=F,
            pos="551,18",
            shape=box,
            width=0.75];
    }
  edge [color=red]
    __Ab    [height=0.05,
        pos="221,73.8",
        width=0.05];
    __Bb    [height=0.05,
        pos="26,73.8",
        width=0.05];
    __Cb    [height=0.05,
        pos="143,73.8",
        width=0.05];
    __Db    [height=0.05,
        pos="289,73.8",
        width=0.05];
    __Eb    [height=0.05,
        pos="415,73.8",
        width=0.05];

    __Ab -- A
    __Bb -- B
    __Cb -- C
    __Db -- D
    __Eb -- E
        __Bb --  __Eb

  edge [color=blue]
    __Ac    [height=0.05,
        pos="236,52",
        width=0.05];
    __Cc    [height=0.05,
        pos="163,52",
        width=0.05];
    __Dc    [height=0.05,
        pos="309,52",
        width=0.05];
    __Ec    [height=0.05,
        pos="435,52",
        width=0.05];
    __Fc    [height=0.05,
        pos="561,52",
        width=0.05];
    __Ac -- A
    __Cc -- C
    __Dc -- D
    __Ec -- E
    __Fc -- F
    __Cc -- __Fc
}
sroush
  • 5,375
  • 2
  • 5
  • 11
  • Jeez that does look like a pain. Where can I find documentation on this PIC language you speak of? I cannot find much about it through google. – BarrowWight Nov 04 '19 at 22:06
  • Original doc: http://doc.cat-v.org/unix/v10/10thEdMan/pic.pdf Gnu version: http://ytdp.ee.wits.ac.za/help/gpic.pdf Best version: https://ece.uwaterloo.ca/~aplevich/dpic/dpic-doc.pdf Look here for dpic: https://ece.uwaterloo.ca/~aplevich/dpic/ – sroush Nov 06 '19 at 03:50
0

Here is an unoptimized version in PIC (dpic). Macros would make it smaller.

.PS
 move down;
 right;
 move right
 B: box "B"; move right
 C: box "C"; move right
 D: box "D"; move right
 E: box "E"; move right
 F: box "F"; move right
 b2cX=C.c.x-B.c.x

 move to C.e + (D.w-C.e)/2; move up 1

 A: box "A" outline "red"
 a2redlineY=A.s.y - D.n.y
 redDeltaYtop=a2redlineY * .5
 redDeltaYbottom=a2redlineY-redDeltaYtop
 blueDeltaYtop=a2redlineY * .75
 blueDeltaYbottom=a2redlineY-blueDeltaYtop

 down
 ############################################################
 # RED
 ############################################################
 # draw line down from  A to the (to be drawn) bus
 X: line down  redDeltaYtop from .25 <A.sw,A.se>  outline "red" 
 Ap: X.s
 line left to ((B.w.x+((B.e.x-B.w.x)*.3)), Here.y) outline "red" 

 line down redDeltaYbottom outline "red"      # down to B
 move up  redDeltaYbottom                     # back up

 line right b2cX   outline "red"              # line to C 
 X: line down redDeltaYbottom outline "red"   # line down
 Cp: X.n
 move up redDeltaYbottom                      # back up

 line right b2cX   outline "red"              # line to D 
 X: line down redDeltaYbottom outline "red"   # line down
 Dp: X.n
 move up  redDeltaYbottom                     # back up

 line right b2cX   outline "red"              # line to E 
 X: line down redDeltaYbottom outline "red"   # line down
 Ep: X.n
 move up  redDeltaYbottom                     # back up


 ### draw connection points
 circle diam .05 shaded "black" with .c at Ap
 circle diam .05 shaded "black" with .c at Cp
 circle diam .05 shaded "black" with .c at Dp

 ############################################################
 # blue
 ############################################################
 # draw line down from  A to the (to be drawn) bus
 X: line down  blueDeltaYtop from .75 <A.sw,A.se>  outline "blue" 
 Ap: X.s
 line left to ((C.e.x+((C.w.x-C.e.x)*.3)), Here.y) outline "blue" 

 line down blueDeltaYbottom outline "blue"      # down to C
 move up  blueDeltaYbottom                     # back up

 line right b2cX   outline "blue"              # line to D 
 X: line down blueDeltaYbottom outline "blue"   # line down
 Dp: X.n
 move up  blueDeltaYbottom                     # back up

 line right b2cX   outline "blue"              # line to E 
 X: line down blueDeltaYbottom outline "blue"   # line down
 Ep: X.n
 move up  blueDeltaYbottom                     # back up

 line right b2cX   outline "blue"              # line to F 
 X: line down blueDeltaYbottom outline "blue"   # line down
 Fp: X.n
 move up  blueDeltaYbottom                     # back up

 ### draw connection points
 circle diam .05 shaded "black" with .c at Ap
 circle diam .05 shaded "black" with .c at Dp
 circle diam .05 shaded "black" with .c at Ep
.PE
sroush
  • 5,375
  • 2
  • 5
  • 11