graphviz - fixed node positions

2019-02-09 14:18发布

问题:

I have a graph that is processed by neato and I'm adding new edges to it. However, I don't want that the old nodes to be moved. I want that neato computes the new positions of the new nodes and the old nodes stay in the same place.

strict graph {
    node0 [pos="1,2"];
    node1 [pos="2,3"];
}

and I add new edges:

strict graph {
    node0 [pos="1,2"];
    node1 [pos="2,3"];
    node1 -- node2 [len="3"];
    ...
}

I want to get the same positions on the old nodes. For example:

strict graph {
    node0 [pos="1,2"];
    node1 [pos="2,3"];
    node2 [pos="3,4"];
    ...
}

How can I do that?

回答1:

You can pin a node's position by setting the node attribute pin=true.

Or put a '!' at the end of the pos attribute: pos="34,12!"



回答2:

Running it with -n option should do the trick.