考虑我们有 Vertex User 和 Edge FriendsWith。 FriendsWith 可以在两个方向上进出(通常是在 2 个用户之间或在 2 个用户之间)。
重复是指从一个用户到另一个用户的出入次数超过一次(出入一起不被视为重复)
有没有办法找到重复的边并删除它们?
更新 添加了说明问题的图片
谢谢。
最佳答案
这是我的 javascript 函数:
var g=orient.getGraph();
var C=g.command('sql','select from FriendsWith');
var arr = new Array(C.length);
var toRemove = new Array();
for(i=0;i<C.length;i++){
var found = false;
for (x = 0; x < i+1 && !found; x++) {
if (arr[x] === C[i].getProperty("out").getId()+" "+C[i].getProperty("in").getId()) {
found = true;
toRemove.push(C[i].getId());
}
}
arr[i] = C[i].getProperty("out").getId()+" "+C[i].getProperty("in").getId();
}
for(a=0;a<toRemove.length;a++){
var C=g.command('sql','delete edge '+toRemove[a]);
}
希望对您有所帮助。 再见
关于orientdb - 在 OrientDb 中查找并删除重复边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34857558/