我想在我的應用程序中合併語義相同的節點。有沒有可用於處理圖形的工具或算法?如何合併圖形中的節點?
輸入示例:節點一個和b應該合併。使用dot
圖形的
digraph g {
a -> {b;c;d;e};
b -> {a;c;d;e};
}
圖片:
輸出示例:節點一個和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
嗨馬丁,我知道這已經很長一段時間了,但你是否設法讓這個工作? – 2018-01-04 08:39:24