[英]neo4j conditional relationship
I am currently working on a program using graph db - neo4j and I need to realize the following function. 我目前正在使用图db-neo4j编写程序,需要实现以下功能。
BTW, I will meet this situation many many times in my program. 顺便说一句,我将在程序中多次遇到这种情况。 Do you guys have any idea how to implement it efficiently. 你们有什么想法如何有效地实施它。
Thanks in advance. 提前致谢。
Suggestion for Setup 安装建议
(Ax)-[:TRUE ]->(Nx)-[:TRUE ]->(Ax+1)
(Ax)-[:FALSE]->(Nx)-[:FALSE]->(Ax+1)
Suggestion for Query 查询建议
MATCH (a:A {id:1}),
(a)-[:TRUE]-> (n)-[:FALSE]->(a2),
(a)-[:FALSE]->(n2)-[:TRUE]->(a2),
(a)-[:TRUE]-> (n)-[:FALSE]->(a2)
RETURN a2;
Thanks to @Michael Hunger, I think I find an acceptable solution, although it seems a lot of work to do. 感谢@Michael Hunger,我认为我找到了一个可以接受的解决方案,尽管似乎还有很多工作要做。
Specifically, I expand all the pathes from A1 through Ni and link the only path when all Ni =true to A2* and all the other paths to A3 as the following graph: 具体来说,我将所有路径从A1扩展到Ni ,并将所有Ni = true时的唯一路径链接到A2 * ,将所有其他路径的所有链接链接到A3 ,如下图所示:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.