简体   繁体   English

如何基于 Neo4j 中的子节点链接在节点之间创建链接

[英]How do I create a link between nodes based on a subnode link in Neo4j

I have a database with two clusters.我有一个包含两个集群的数据库。 There is a hard link between the nodes near the bottom.靠近底部的节点之间存在硬链接。 But when you select just the top nodes, I would like to see that the root nodes are connected somehere.但是当你 select 只是顶部节点时,我想看到根节点连接到这里。

提取图片 - 显式存在,需要生成“生成”

So the links at the bottom are connected but when you select only the top nodes, I would like to show that at some point (any point) these are connected.所以底部的链接是连接的,但是当你 select 只有顶部节点时,我想表明在某个点(任何点)这些是连接的。

1) I can find the link to between groups by matching a child connection where the target has different groupid (group id is on every node) 2) I think I then have to run up the tree and find the root node. 1)我可以通过匹配目标具有不同 groupid 的子连接(组 id 在每个节点上)来找到组之间的链接 2)我认为我必须运行树并找到根节点。 I can't seem to make that work.我似乎无法完成这项工作。 I can see it, but can't come up with the cypher to do it.我可以看到它,但想不出 cypher 来做到这一点。 It would be a node with no parents.这将是一个没有父节点的节点。 3) then link (with a different link ID:peerLink)) from group a to group b. 3)然后从组a链接(使用不同的链接ID:peerLink))到组b。 Thats easy enough to do once I have 2一旦我有 2 这很容易做到

I am having a beast putting them together.我有一个野兽把它们放在一起。 I did create a separate field for a list of peerLinks so they didnt confuse my parent logic.我确实为 peerLinks 列表创建了一个单独的字段,因此它们不会混淆我的父逻辑。 So again, the goal is to produce the dashed line based on subnode connection.同样,目标是基于子节点连接生成虚线。

I DON'T Need to show it at the sublevels.我不需要在子级别显示它。 They will appear in the UI as an offpage connector它们将作为页外连接器出现在 UI 中

Anyone done this before?以前有人做过吗?

Can you please try this?你能试试这个吗?

MATCH (A_leaf)->(B_leaf)
WHERE A_leaf.GroupID <> B_leaf.GroupID
WITH A_leaf
MATCH (A_leaf)<-[*]-(A_root)
WHERE NOT (A_root)<-()
WITH B_leaf
MATCH (B_leaf)<-[*]-(B_root)
WHERE B_leaf.GroupID == B_root.GroupID
AND NOT (B_root)<-()
CREATE (A_root)-[:relName]->(B_root)

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

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