graphviz - compare graphic trees

妖精的绣舞 提交于 2019-12-06 14:52:24

Given two .dot files, a1.dot:

digraph g1 {
    A -> B -> D -> E
    A -> C -> E
    }

... and a2.dot:

digraph g2 {
    A -> B -> F -> E
    A -> C -> F
    }

... you can find the nodes that are different between them as follows:

$ dot -Tplain a1.dot | sed -ne 's/^node \([^ ]\+\).*$/\1/p' | sort >a1.nodes
$ dot -Tplain a2.dot | sed -ne 's/^node \([^ ]\+\).*$/\1/p' | sort >a2.nodes
$ diff a1.nodes a2.nodes
4d3
< D
5a5
> F

I'm using sed to strip the list of node names for each .dot file out of the plain output from dot, sorting the nodes into order and then using diff to find the differences. This approach doesn't present the differences graphically, but that is a tricky thing to do at the best of times.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!