1

I've the following graph :

digraph G {
    user1  -> SuperUser
    user2  -> SuperUser
    user3  -> SuperUser
    user4  -> SuperUser
    user5  -> SuperUser
    user6  -> SuperUser
    user7  -> SuperUser
    user8  -> SuperUser
    user9  -> SuperUser
    user10 -> SuperUser
    user11 -> SuperUser
    user12 -> SuperUser
    user13 -> SuperUser
}

And I render it using :

$ dot -Tpng test_dot -o test_dot.png

Does a way exists to avoid a render too much horizontal like that ? enter image description here

I know that I could use rankdir = LR but my problem would be the same I thought enter image description here

I Want an organisation on more than one level, is it possible ?

Edit: the answer of tk421 is good but I forgot to add that my graph is pretty big and has an unpredictable size so the solution can't be "manual"

snoob dogg
  • 2,491
  • 3
  • 31
  • 54
  • It would help if you give us a bit more precise idea what you want the end result to look like. The answer to your question is "yes", and @tk421 has given the basic concept. For more, please more input! – vaettchen Jul 20 '18 at 12:00
  • Regarding the depth, do you write out yourself the notes (i.e. do you have influence on the writing). If the later is the case and you know the number of "nodes" you can also calculate the number of required ranks and add that to the file, otherwise some scripting as suggested in a comment of the answer tk421 might be the best solution. – albert Jul 21 '18 at 08:51

1 Answers1

1

Yes. You can use rank and invisible links (style = invis) to create levels like so:

digraph G {
    user1  -> SuperUser
    user2  -> SuperUser
    user3  -> SuperUser
    user4  -> SuperUser
    user5  -> SuperUser
    user6  -> SuperUser
    user7  -> SuperUser
    user8  -> SuperUser
    user9  -> SuperUser
    user10 -> SuperUser
    user11 -> SuperUser
    user12 -> SuperUser
    user13 -> SuperUser
    user5 -> user4 [ style = invis ];
    user9 -> user10 [ style = invis ];
    { rank = same; user1; user2; user3; user4 }
    { rank = same; user5; user6; user7; user8; user9 }
    { rank = same; user10; user11; user12; user13}
}

This would produce:

enter image description here

Of course, you could play around with this to get it to look how you want.

There are also other layout style tools as part of the graphviz package. For example, if you want a more circular graph, you can use twopi instead of dot.

$ twopi -Granksep=2  sample.dot -o twopi.png

enter image description here

Refer to Graphviz's Documentation for more information.

tk421
  • 5,775
  • 6
  • 23
  • 34