我希望合并在我的应用程序中语义相同的节点。是否有一个工具或算法可以用来处理我的图形?
输入示例:应该合并节点、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
https://stackoverflow.com/questions/14966157
复制相似问题