graphviz-比较图形树 [英] graphviz - compare graphic trees

查看:103
本文介绍了graphviz-比较图形树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须用graphviz做事.我需要可视化几棵树的图形表示形式,但是无论如何我都必须比较两棵树以查看它们之间的差异:像这样,我有树A和树B.创建它们的表示并进行比较之后,我只需要查看没有共同点的节点.有人告诉我使用EMF Compare,但不幸的是,我不知道如何使该插件接受graphviz的扩展.

I have to do a job with graphviz. I need to visualize the graphic representation of several trees, but in any case I have to compare two tree to see their differences: something like this, I have tree A and tree B. After create their representation and compare them I need to see only the nodes that don't have in common. Someone told me to use EMF Compare but unfortunately I don't know how to make this plugin accept the extension of graphviz.

有什么建议或其他可能的解决方案来应对这项工作吗?

Any advice or any other possible solution to face this job?

致谢.

推荐答案

给出两个.dot文件a1.dot:

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

...和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

我正在使用seddotplain输出中剥离每个.dot文件的节点名称列表,将节点按顺序排序,然后使用diff查找差异.这种方法不能以图形方式显示差异,但是在最佳情况下这样做是一件棘手的事情.

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.

这篇关于graphviz-比较图形树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆