1

示例数据库:TinkerPop Modern


目标:查找尚未开发软件的人。

IE。不直接连接到顶点类型“软件”的顶点类型“人”

与软件相关的人员 [作品]

g.V().hasLabel("Person").as("from")
.project("title", "node")
    .by(select("from").unfold().values("name").fold())
    .by(select("from").unfold().label().fold())

查找未连接到软件的人员 [不起作用]

g.V().hasLabel("Person").as("from")
.filter(both().not(hasLabel("Software")))
.project("title", "node")
    .by(select("from").unfold().values("name").fold())
    .by(select("from").unfold().label().fold())

我相信它忽略了不满足条件但不跳过顶点的边缘。

试图做一个循环,但没有找到一个例子。

Cypher Query 等效项(仅供参考): MATCH (n:People) WHERE NOT (n)--(:Software) RETURN n


样本数据库:

在此处输入图像描述

4

1 回答 1

1

我相信您只需要更改过滤条件:

gremlin> g.V().hasLabel('person').
......1>   filter(__.not(outE('created'))).
......2>   project("title", "node").
......3>     by('name').
......4>     by(label)
==>[title:vadas,node:person]

如您所见,您也不需要as()出于任何原因选择回到该步骤 - 您已经将该顶点作为当前遍历器在project().

于 2018-05-05T11:00:56.987 回答