Strange line routing and node placement

Hello together

I'm new to Graphviz/Dot and tried to create my first Dot-Diagram. The Basics went very quick but Fixing the layout took me much time and I think I'm lost enough time now and better ask for help by more experienced People...

It's about the routing of a line which I already tried to fix by telling where to locate the line at the nodes as describe at http://stackoverflow.com/questions/4106972/strange-edge-placement-in-gra....
This worked but the Routing is the same strange Thing (should bi right instead of left through all content).

The second one is the node Placement of the three bottom nodes left. This could be placed much better so that the diagram would fit perfect on a Portrait A4 page...

You can see a Picture and the code here: http://stackoverflow.com/questions/23980422/graphviz-dot-strange-edge-ro...

any ideas how to fix this or what causes the Problem? the line Routing simply makes no sense when it could be right straight away where no other line is.

Nobody any idea or suggestion

Nobody any idea or suggestion how to fix this?

In a week I have to hand in my report...

 

thx

Sorry, I added a note to

Sorry, I added a note to http://stackoverflow.com/questions/23980422/graphviz-dot-strange-edge-ro... but must have forgot to commit my note here.

If the edge placement problem refers to the edge "Success2":e -> "idle":n going to the left rather than straight up, the reason is that dot wants to minimize edge crossings. Any other path would cause at least 1 crossing, so the current path is picked as having only 1 crossing. As for the 3 left bottom nodes, the dot algorithm wants to make the edges as short as possible, while trying to respect edge directions, so the "best" solution is to place them side by side. So dot is doing what it supposed to do given the constraints. One way to fix the second problem would be to add minlen=2 to the edge "isTarget (flash mode)" -> "Acknowledge2".

However, I would recommend a different course, using fewer constraints. If your graph has a natural flow, that is the order in which the nodes and edges should be described. This should minimize the need to add constraint=false attributes. For example, you obviously want Success2 and Success1 at the bottom, so they should not be mentioned at the top of the graph. If you consider the "PowerUp" node as the root, the remaining edges and nodes should occur in DFS order. Also, if node A appears before node B, and they are on the same rank, it is likely that node A will be to the left of node B. For this reason, I would list "Wait for \"Enter bootloader\" request" -> "Start Firmware" before "Wait for \"Enter bootloader\" request" -> "Enter bootloader". Basically, just describe the graph in a natural top-down order, and avoid adding structural constraints unless it is really necessary to get what you want.

Another suggestion concerns edge labels. Edge labels are treated at dummy nodes. This often works well, but sometimes this heavyweight approach can distort the layout, especially for long labels. I would consider changing some, or many, of the longer edge labels to xlabels. In this way, they are placed after the basic layout is done.

Note that the rankdir attribute has no effect within a subgraph. It only affects the root graph.

Anyway, here is how I would restructure your graph file giving the result.

 

p.s. for me, the weight

p.s. for me, the weight attribute makes no difference...

Which weight attribute?

Which weight attribute?

I don't understand I posted a

I don't understand I posted a long response and it is gone...!?!
Maybe I didn't click save after preview...?!?

 

Anyway, I managed now to get the line going right even thow I still don't understand why. I don't see how the definition position affects the routing.
For having it look right and not having the other success line going through everyting I have to have the Success1 node at the top of my whole graph.

Up to now I thought these are just definitions and possibly may affect the placement order but nothing else.

 

With your solution I have two major problems:
- Actually, I want it just like I have it just with those two things mentioned. Your solution doesn't look that good and clear structured to me anymore as mine did.
- Your x label may simplify the routing but therefore they cross everthing which looks very ugly to me.

 

Too, is it possible to change the label alignment?

Thank you very much & best regards...

Another trick is to use the

Another trick is to use the ordering attribute to make sure edges leave in the order you want.

Or replace the edge

  "Success2":e -> "idle":n [constraint=false]

with

        x [shape=point width=0 height=0]
        idle -> x [dir=back]
        x -> "Success2" [dir=none]

 

Hello Frist, thank you very

Hello
Frist, thank you very much!

If the edge placement problem refers to the edge "Success2":e -> "idle":n going to the left rather than straight up, the reason is that dot wants to minimize edge crossings. Any other path would cause at least 1 crossing, so the current path is picked as having only 1 crossing.

I don't understand. Like it is it crosses multiple lines. If it goes right like you did, it crosses nothing...!

With your solution I have two major problems:

1st, the layout doesn't look that good to me anymore and the node placement is very different than mine are. Actually, I'd like everything just like it is except the weird line going left and the three nodes that wide that it doesnt fit on a portrait page right anymore.

2nd: The xlabels may simplify the routing and placement but in my opinion this is very ugly going through everything and therefore no opinion to use it like this in my report.

But I'll look further at your code and maybe it'll help me for further graphs.
For the moment I was just glad to finally have it look like I wanted except those two things...
Can you help me achieve that it looks exactly like I want? ;)

Thank you very much!

I don't understand. Like it

I don't understand. Like it is it crosses multiple lines. If it goes right like you did, it crosses nothing...!

As it does in my drawing. The problem is that the crossing reduction pass uses a heuristic. It is quite possible to end up in a local minimum. Your eyes see immediately that you can flip the edge to the right but the algorithm works by modest shifts two levels at a time. It may never get to a state where is can easily move the entire edge to the right.

My layout is differerent, but to my eyes it looks fine. Maybe there is some aspect you are trying to emphasize that I am not aware of. In any case, my two meta-points are 1) start with minimal constraints and attributes and only add as needed, and 2) input order matters (barring explicit constraints), so describe nodes and edges that follow the flow. In particular, earlier nodes will often appear above (or to the left) of later nodes.

Another thing you might try is to reverse the troublesome edge, using the dir attribute. That is, replace

  "Success2":e -> "idle":n [constraint=false]

with

  idle -> Success2 [dir=back]

As for xlabels, try using just enough get a better layout. To me, that terrible bend around the label on the left is much uglier than having a smoother edge with a label overlapping some edges.

Hello Thank you very much!

Hello

Thank you very much! Without your help I hadn't been able to manage fixing this!
I wanted to say it days ago but first the posts we're outstanding for moderation/check before they got published and then the last i couldn't issue any more because of the spam filter.

With the awareness that already the definition order matters I was able to fix some things, also I found the dir=back which too helped mi fix some things (in the current and a new graph).

 

P.S. This is what I wanted to post days ago (unfortunately I cannot post the code because of the spam filter but I can't do it otherwise if you're interested):

Hey I now managed it to get it nearly exactly as I wanted... :D

Thank you very much for the hint of the order of the definition which I didn't know that this really matters...
Too thank you for the xlabel hint! This helped me some times getting a better layout.

And finally, to get it right with the left "Success" I have to go "backwards" (idle->success->istarget) and use dir=back.

Recent comments