我试图使用 Scala 探索 janusgraph。
因此,对于给定的顶点 v1 和 v2,我想知道是否存在具有特定属性值的从 v1 到 v2 的有向边并检索该边。
在 gremlin 中,我们通常会做,
g.V(v1).outE().where(otherV().is(v2)).hasNext()
检查边是否存在并
ed = g.V(v1).outE().where(otherV().is(v2)).next()
获取边缘。
那么,scala中相应的查询是什么?似乎无法以类似的方式使用 otherV()
。
谢谢。
最佳答案
otherV()
在您使用它的上下文中,是 anonymous traversal它是从 __
类生成的。要么从该类静态导入 otherV()
(这就是 gremlin 控制台所做的),要么只是完整引用它:
g.V(v1).outE().where(__.otherV().is(v2)).hasNext()
关于scala - Janusgraph - 检查和获取两个顶点之间的边缘的有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50290795/