假设我有一个节点链/列表:
(:node {uid:333})-->(:node {uid:102})-->(:node {uid:155})-->...
我想用另一个节点链替换一个或多个连续的节点。
(:node {uid:255})-->(:node {uid:107})
在我看来,实现这一点的操作数量太多,无法在单个查询中进行。
1. input [255,107]
2. create the (255)-->(107)
3. find the place where to insert in the original chain
4. connect this node to (255)-->(107)
5. connect the tail-107 to the original chain (if it does not end)
6. delete the part to be replaced..
问题是,如果它不是单个查询,那么它将变得更加复杂。
你会怎么做?(必须像字符串替换一样工作(
简化它的一个想法是找到链中的位置并使用索引。
我希望我正确理解了你的问题
MATCH ({uid:333})-[]->(s {uid:102})-[e0]->({uid:155})-[e1]->()
CREATE (s)-[:R]->({uid:255})-[:R]->({uid:107})
DELETE e0, e1
MATCH将找到您要修改的链。
CREATE将引入新的子链。
DELETE将断开要替换的原始子链,具体取决于您可能希望删除替换的节点而不是边的使用情况。