5

I want to render a graph in similar layout to the following one:

wanted

I tried this:

digraph EDP
{
  graph [colorscheme=paired12];
  node [label="\N", shape=box, style="rounded,filled", colorscheme=paired12, color=8, fillcolor=7, width="1.2", fontname="Arial narrow", fontsize=12];
  edge [colorscheme=paired12, color=8, fontsize=11, fontname="Arial narrow"];

  src [label="Source"];
  dst [label="Destination"];
  filter [label="Filter"];

  src -> dst [label="Encoding process"];
  src -> filter [label="a"];
  filter -> dst [label="b"];
  src -> filter [dir=back, label=c];
  filter -> dst [dir=back, label=d];
  src -> dst [dir=back, label="Decoding process"];

}

which generated the following result :( Not very nice...

my

Can anyone show me the closest possible solution? (Probably it is not possible make exactly the same)

einpoklum
  • 118,144
  • 57
  • 340
  • 684
clt60
  • 62,119
  • 17
  • 107
  • 194

1 Answers1

9

As close as I got before calling it a night:

digraph EDP
{
  graph [colorscheme=paired12];

  node [label="\N", shape=box, style="rounded,filled", colorscheme=paired12, color=8, fillcolor=7, width="1.2", fontname="Arial narrow", fontsize=12];
  edge [colorscheme=paired12, color=8, fontsize=11, fontname="Arial narrow"];

  src [width=3.5, label="Source"];
  dst [width=3.5, label="Destination"];
  filter [label="Filter"];

  edge[constraint=false];
  src -> dst [label="Encoding\nprocess"];
  src -> filter [label="a"];
  filter -> dst [label="b"];
  dst -> filter [label="c"];
  filter -> src [label="d"];
  dst -> src [label="Decoding\nprocess"];

  edge[style=invis, constraint=true];
  src->filter->dst;

}

Save the graph as edp.gv and create the image with

dot -Gsplines=none edp.gv | neato -n -Gsplines=ortho -Tpng -o edp.png

Result:

closest possible graphviz output

Some remarks:

  • I ended up putting constraint=false on all edges, and add invisible edges to have the three nodes centered
  • Usually I like to use dir=back, but I wasn't able to use this when rendering with -Gsplines=ortho
  • As you can see, the order of the edges is random...
marapet
  • 54,856
  • 12
  • 170
  • 184
  • Man, youre an graphviz wizzard! Thanx, thats cool. Must learn something about "neato" - never used it yet... – clt60 Nov 29 '11 at 23:33
  • I'm glad it helps! Take a look at the neato documentation, in this case, the `-n` flag is what tells neato to _not_ calculate the position of the nodes (they were calculated by dot). – marapet Nov 29 '11 at 23:39