aisensiy
aisensiy

Reputation: 1520

How can I give a graph nodes fixed position in graphviz and how can i make the edges not overlapped?

I have seen some similar questions here, but the answers dont solve my problem.

I want to draw a graph. I write some code like this:

digraph {
  {rank = same a b c d e f }
  a -> b -> c -> d -> e -> f
  a -> f
  b -> d -> f
  b -> f
}

but the result is that some of the edges overlapped each other.

So my question is how can I fix the edge to make it not overlap and I also wanna know how can I give the node a fixed position? There is no problem this graph. But some times when I wanna a graph with a sequence of

a b c d e f 

but when i create some edges and the sequence will change like:

a->e b c d f

Upvotes: 2

Views: 1783

Answers (1)

dgw
dgw

Reputation: 13646

You can use the attribute pos of a node or edge to specify coordinates. To see where dot places your nodes and edges you can simply run dot myinputfile.dot without any output parameter. This will produce the dot file with added coordinates (among other additions).
Based on this you can force dot to place some or all nodes at certain coordinates.

Upvotes: 8

Related Questions