orientdb - 在 OrientDb 中查找并删除重复边

标签 orientdb orientdb-2.1

考虑我们有 Vertex User 和 Edge FriendsWith。 FriendsWith 可以在两个方向上进出(通常是在 2 个用户之间或在 2 个用户之间)。

重复是指从一个用户到另一个用户的出入次数超过一次(出入一起不被视为重复)

有没有办法找到重复的边并删除它们?

更新 添加了说明问题的图片

enter image description here

谢谢。

最佳答案

这是我的 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/

相关文章:

java - 尝试通过 Graph API 使用 OrientDB 获取 ORecordBytes 时发生 ClassCastException

mysql - Orientdb GC overhead limit exceeded/out of memory 错误和性能低下

sql - OrientDB - 按日期分组查询

orientdb - 从集群名称请求集群 ID

graph-databases - 使用 OrientDB 递归遍历有向边

python - 检查 OrientDB 中的类创建

orientdb - 如何使用 Gremlin 在 orientdb 中创建自定义类

python - requests/httplib/urllib 返回 3 个不同的结果

caching - OrientDB中的磁盘缓存如何按读缓存和写缓存分开(百分比)

orientdb - 我们可以在 orientdb 中更新一条边吗?