Equal nodes?

Is there a way to tell dot that a node and another one are the same, even if they have different labels?

I have these nodes (which are names of sets)

(q0 q2 q1)

(q0 q1 q2)

Also, I have these two:

(q2 q1) (q1 q2)

So, in set theory, they're equivalent.

But Dot doesn't know that, so instead, it creates 2 different nodes. I could make the combinations of items in the sets, and then put them there but Dot draws them even if there's no edge that leads to them.

Is there a way to:

1.- Tell Dot that a=b where a and b are different node tags?

2.- Tell Dot not to draw a node a if no edge leads to them? Thanks in advice! :)

ceps-afd.png35.52 KB

In Graphviz graphs, the node

In Graphviz graphs, the node name is its key. That is, if two nodes have the same name, they are the same node; if they have different names, they are different nodes. So any equivalence relation you want needs to be supported by you. In particular, dot has no model of set theory built in. So the answer to question 1 is no. Node tags (names) determine equality.

For the second question, the layout programs draw the graph given as input, so if there is something you don't want drawn, this has to be supplied as part of the input, either when creating the graph or by preprocessing. An easy way to do this is to use gvpr. For example, the command pipeline

    gvpr -c 'N[$.degree==0]{$.style="invis"}' yourgraph.gv | dot -Tpng > yourgraph.png

will make all nodes without edges invisible in the drawing. They will take up space, so you may want to use {delete($G,$)} instead as the action.

Recent comments