hilby84
November 17, 2021, 2:21pm
1
Hello, i am doing a graph and I wonder how I can change the position of nodes that are on the same rank. Here is an example:
graph G{
rankdir = LR;
n0 [shape=Mdiamond]
n1 [color="red", style=filled]
n2
n3
n4
n5
n6
n7
n8
n9
n10
n11
n12
n13
n14
{ rank=source n0 }
ordering="in"
n0 -- n1
n1 -- n2
n2 -- n3
n2 -- n4
n2 -- n5
n5 -- n6
n6 -- n7
n7 -- n9
n7 -- n8
n9 -- n10
n9 -- n11
n9 -- n12
n12 -- n13
n13 -- n14
}
This creates this output:
I want to change the position of node n4/n5 and/or n8/n9. Changing the order in the code does not have any effect.
How can I do that?
Thanks in advance and best regards
Hilby
hilby84
November 17, 2021, 4:31pm
2
Hello everyone, I was able to solve the issue on my own and want to share my solution. The position of the node is determined by the nodelist that is given before defining the graph structure. If there is some other way, feel free to let me know. For now this solved my issue. My New code:
graph G{
rankdir = LR;
n0 [shape=Mdiamond]
n1 [color="red", style=filled]
n2
n3
n5
n4
n6
n7
n9
n8
n10
n11
n12
n13
n14
{ rank=source n0 }
ordering="in"
n0 -- n1
n1 -- n2
n2 -- n3
n2 -- n4
n2 -- n5
n5 -- n6
n6 -- n7
n7 -- n9
n7 -- n8
n9 -- n10
n9 -- n11
n9 -- n12
n12 -- n13
n13 -- n14
}
creates:
Best wishes
Hilby