state diagram -- order of declarations

0 votes
asked Aug 20, 2016 in Bug by noamtm (120 points)

This looks like a bug, but maybe I'm just doing something wrong.

Please explain why this produces an elegant diagram:

[*]-->A
A->B
B->A
B->C
C->B

http://plantuml.com/plantuml/uml/YzQArTMrS-HorBLpud82iO24CvSpa0i0

While this creates a mess:

[*]-->A
B->C
C->B
A->B
B->A

http://plantuml.com/plantuml/uml/YzQArTMrS-HoqhLpvdBMjNFYSWGHGAuZ0000

Statechart-wise, they are the same.

Note that a very small change, changing "[*]-->A" to "[*]->A", makes them both look exactly the same.

http://plantuml.com/plantuml/uml/YzQArRLpv7BIjNFcSjQrS-9o1150hYC0

 

But in my (less trivial) case, I prefer the initial connector to A to be vertical (it makes the entire diagram clearer).

 

2 Answers

0 votes
answered Aug 21, 2016 by plantuml (158,940 points)
Unfortunatly, there is nothing we can do about this, because it's GraphViz/Dot that decide the final drawing, and we have few control over it.

The order of state definition has indeed an impact, but it's difficult to know exactly the rules.

Sorry about that.

About arrow, --> means vertical arrow, and -> means horizontal arrow, and this is a way of controlling the layout done by GraphViz/Dot.

Hope this helps!
0 votes
answered Aug 22, 2016 by fredizzimo (260 points)

I know that this doesn't solve your immediate problem. But it might be fixable quite soon.

Look at this http://plantuml.sourceforge.net/qa/?qa=4842/graphviz-is-not-good-enough

I tested your diagrams with OGDF, and both produces the exactly same layout, at least for the PlanarizationLayout with the settings that I had.

It generates a slightly different output than the PlantUML default though, as it puts the entry point on the same row as the states, but otherwise it's equal to your first example.

...