简体   繁体   English

如何在Cayley Graph数据库中递归读取链接节点?

[英]How to read linked-nodes recursively in Cayley Graph Database?

The database has nodes which form a tree. 数据库具有形成树的节点。 Each node follows another with the predicate "precedes". 每个节点都跟随另一个节点,谓词“先于”。 I want to write a query that can read the entire tree given the start node. 我想编写一个查询,可以在给定起始节点的情况下读取整个树。

I have tried Morphism, but the output makes no sense to me at all. 我尝试了态射,但输出对我来说毫无意义。 Perhaps because of my lack of understand on what "Morphism" actually means ... 也许是因为我对“态射”的实际含义缺乏了解......

Any hints, or links to actual good examples would be appreciated 任何提示或实际良好示例的链接将不胜感激

As @Bruno pointed out in his answer, the equivalent of * in Gremlin is FollowRecursive(). 正如@Bruno在他的回答中指出的那样,Gremlin中的*相当于FollowRecursive()。

var c1 = g.M().Both("precedes")
g.V("chain-1").FollowRecursive(c1).All()

One key thing here is the .Both part in the Morphism Query. 这里的一个关键问题是在态射查询的。两者的一部分。 It encodes that the direction of the predicate should be both In and Out. 它编码谓词的方向应该是In和Out。 I am not sure how that maps to the Neo4j query pattern 我不确定如何映射到Neo4j查询模式

In Neo4j you should do something like this: 在Neo4j中你应该做这样的事情:

MATCH p = (:Root)-[:precedes*]-()
RETURN p

Note that the * specified after the relationship type will do a full search in the entire graph. 请注意,在关系类型之后指定的*将在整个图形中执行完整搜索。 It can cause memory issues. 它可能会导致内存问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM