2

How to set the order of the nodes in one layer by the order of the definition of edges rather than the definition of nodes when using dot to draw a tree diagram?

For example, For some reasons i need to first define node1, node2, and node3, and then draw the edges: node3 -> node2, and node3 -> node1, and i hope that the edges are drawn as they are defined.

below are the .dot files

digraph G {
    node1 [label = 1];
    node2 [label = 2];
    node3 [label = 3];
    node3 -> node2;
    node3 -> node1;
}

fig 1. node2 on the right

but I want it to be like this:

fig 2. node2 on the left

How can i realize this? Thank you for help.

How to set the order of the nodes in one layer by the order of the definition of edges rather than the definition of nodes when using dot to draw a tree diagram?

albert
  • 8,285
  • 3
  • 19
  • 32
  • Possible duplicate of https://stackoverflow.com/q/9167887/13785815. Short answer: add line `ordering=out;` after the first line. – Simon Smith Jan 02 '23 at 11:28

0 Answers0