我如何获得关系的结束节点。 例如:Py2neo与Neo4j的关系
rels = graph_db.match(start_node=user, rel_type="is_post_owner")
所以,我怎么能得到的起始节点用户的所有终端节点。
问候,萨穆埃尔
我如何获得关系的结束节点。 例如:Py2neo与Neo4j的关系
rels = graph_db.match(start_node=user, rel_type="is_post_owner")
所以,我怎么能得到的起始节点用户的所有终端节点。
问候,萨穆埃尔
筛选的端节点:从所述match
方法返回
rels = graph_db.match(start_node=user, rel_type="is_post_owner")
end_nodes = [rel.end_node for rel in rels]
每个关系是一个标准Relationship OB ject并且可以这样使用。
你可以使用暗号
START a=node(id) //replace with the id of the node you want to start
MATCH p=a-[:is_post_owner*..]->x //get all the paths to all nodes with rel:is_post_owner
WHERE NOT(x-->()) //exclude nodes with Direction Out Relationships "end nodes"
RETURN x //get the end nodes
这样返回的节点都将是你的图形的叶节点,与方向没有别的关系。
正如托马斯所说,他绝对正确,你应该在where子句中包含关系类型。这样你只能得到那个关系的末端节点,并且返回的节点可以有其他的关系。叶节点),但它们是所请求的关系
START a=node(id)
MATCH p=a-[r:is_post_owner*..]->x
WHERE NOT(x-->(r))
RETURN x
您应该将关系类型添加到WHERE中,否则可能会有其他不相关的关系类型 – 2013-05-13 09:54:45