【发布时间】:2013-02-19 19:52:54
【问题描述】:
我想合并在我的应用程序中语义相同的节点。有什么工具或算法可以用来处理我的图表吗?
输入示例: 节点 a 和 b 应合并。
digraph g {
a -> {b;c;d;e};
b -> {a;c;d;e};
}
使用dot的图形图像:
输出示例: 节点 a 和 b 已合并为节点 ab。
digraph g {
ab -> {c;d;e};
}
粗略草图算法:
# XE = a set of nodes, represent a directed edge (x,_)
# YE = a set of nodes, representing a directed edge (y,_)
# XE \ y = XE except y
# YE \ x = YE except x
For each pair of nodes x,y
If (edges (x,y) and (y,x) exists) AND (XE \ y == YE \ x)
create new node xy -> xedges\y
delete nodes x and y and their edges
【问题讨论】:
-
嗨,Martin,我知道这已经很长时间了,但你设法让它工作了吗?
标签: graph graphviz graph-algorithm