如何使用 Gremlin 3 删除具有特定 inVertices 的传出边?

How to drop outgoing edges except those with specific inVertices using Gremlin 3?

如果它们的 inVertices 不包含在 donttouch 的列表中,我想删除顶点 entity 的出边。

我有这样的遍历:

g.V(id).as("entity")
 .V(id2).as("donttouch1")
 .V(id3).as("donttouch2")
 .outE("hasType").drop();

以上查询存在三个问题:

所以我需要这样的东西:

String[] donttouch= {"donttouch1","donttouch1"};

g.V(id).as("entity")
 .V(id2).as("donttouch1")
 .V(id3).as("donttouch2")
 .back("entity").outE("hasType")
 .where(not(inV().hasId(P.within(donttouch)))).drop().select("entity").next()

donttouchs 的列表可能很长,所以我宁愿把它们放在一起,而不是作为 neqs

的连词

谢谢!

我假设 untouchable ids 列表已经存在于列表/集合中。在这种情况下你可以这样做:

g.withSideEffect("x", untouchableIds).
  V(id).outE("hasType").not(inV().id().where(within("x"))).drop()