How to make GraphVis optimize graph like the following

I have a msc like graph like below example where dot aparently make non optimal layout
is there a way to optimize this without manualy inverting some of the edges?
By optimize I mean make callA appear callB in stead of below (Obvious what was intended
but also seems to be most optimal for shortest edges but somehow dot get confused)

digraph{
size=13
rankdir=LR
{
node[shape=box]
//edge[style=invis]
edge[weight=100]
Du->WSu->SCu
Du_->WSu_->SCu_
}
{
node[shape=point label=""]
//edge[dir=none]
edge[color=gray]
{ rank=same Du->Du1->Du2->Du_ }
{ rank=same WSu->WSu2->WSu3->WSu_ }
{ rank=same SCu->SCu0->SCu1->SCu_ }
}
{
edge[weight=10]
Du2->WSu2[xlabel=callA]
WSu3->SCu1[xlabel=callB]
SCu0->Du1[xlabel=show]
}
}

If dot handled flat edge

If dot handled flat edge crossings, this wouldn't occur. Unfortunately, this combined with rankd=LR involving a rotation and a reflection, dot gets confused. There is probably no simple solution. It is possible that some re-ordering of the nodes and edges would push dot in the right direction, but that would still take some work. My preference is to forgo rankdir=LR and think about time going from bottom to top. The constraints you add specify which nodes occur at the same time. This leads to the input

    digraph{
        size=13
        node[shape=box]
        {rank=same Du->WSu->SCu}
        {rank=same Du_->WSu_->SCu_}

        node[shape=point]
        edge[color=gray]
        Du->Du1->Du2->Du_
        WSu->WSu2->WSu3->WSu_
        SCu->SCu0->SCu1->SCu_
        {rank=same SCu0 Du1}
        {rank=same Du2 WSu2}

        edge[color=black constraint=false]
        SCu0->Du1[xlabel=show]
        Du2->WSu2[xlabel=callA]
        WSu3->SCu1[xlabel=callB]

    }

Another simple approach is to use your current graph minus the rankdir statement, do a layout, use gvpr to rotate and reflect the layout, and then render it using neato -n.

 

rewriting vs gvpr vs rankdir

Hi 

Thanks for your feed back, I tried rewriting my more complex drawing as you have done in the simple examle but ran in to several issue mainly that building an xy grid with rank=same and  weight=100 depend on all row being present in the node chain where weight=100 is being applied

Just removing rankdir and set rotate=90 instead seems to do the work on my more complex drawing though I have a hard time wrap my brain around time flowing upward.

So I tried gvpr  and the rotate script example with a minor change to invert the y-axis, I only had a minor problem that neato apparently do not give a default label to nodes so I also tried:

  • Adding 'node[label="\N"]' with no effect
  • adding 'if (!hasAttr($,"label")) $.label = $.name;' to N{...} in rotate script with no effect
  • adding 'if ($.label == "") $.label = $.name;' to N{...} in rotate script wich worked since there is no nodes with intentional empty labels

Do you happen to know what are the problem in the first two attempts?

Recent comments