仅当同一标签的另一条边不存在时,才在两个带标签的顶点之间添加一条边?

Add an edge between two labeled vertices only if another edge of the same label doesn't exist?

我的traversal:

g.V(id1).as("entity")
 .V(id2).as("type1")
 .addE("hasType").from("entity").to("type1");

我想对其进行更改,以便仅在相同 edgeLabel 的另一条边不存在于相同顶点之间时才添加这条边。

谢谢!

这使用where步骤在继续之前查看是否有来自"entity"的传入边(从"type1"的角度)。

g.V(id1).as("entity").
  V(id2).as("type1").
  not(__.in("hasType").where(eq("entity"))).
  addE("hasType").from("entity").to("type1")