Neo4j链表-多个节点 [英] Neo4j linked list - multiple nodes

查看:91
本文介绍了Neo4j链表-多个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力了解如何使用链接列表来提高性能并在Neo4j上创建活动供稿..仍在学习Cypher,所以我有一个问题..我找到了一些链接列表的示例,但是我需要带有更大示例的列表,以便最终将所有内容组合在一起..

I'm working on understanding how to use linked lists to improve performance and create activity feeds on Neo4j.. Still working on learning Cypher, so I have a question.. I've found some examples of linked lists, but I need lists with bigger examples to finally put all the pieces together in my head..

我已经从

I've used this code from grepcode and have found it to be more helpful than the example in the Neo4j manual. Yet I'm still a bit confused.. Can someone modify it to have say seven nodes with seven items in the linked list, and then insert a node on the front of it?

是的,我正在尝试将最新状态更新放在链接列表的顶部.这个示例并没有真正做到这一点,但是已经接近了...因此,我们正在寻找一些mod..不,我还没有真正编写代码,仍然想先掌握Cypher,接下来的两周将继续研究它. .让Ruby on Rails端正常工作..只需要更好地了解与Cypher/Neo一起使用的链表即可.

Yea, I'm trying to put the latest status update on the top of the linked list. This example doesn't really do that, but it's close.. so looking for some mods.. No, I'm not really coding yet, still trying to master Cypher first - will continue to study it for the next two weeks... Have the Ruby on Rails side working .. just need to understand linked lists used with Cypher/Neo a bit better.

CREATE zero={name:0,value:0}, two={value:2,name:2}, zero-[:LINK]->two-[:LINK]->zero

==== zero ====

MATCH zero-[:LINK*0..]->before,
after-[:LINK*0..]->zero,
before-[old:LINK]->after
WHERE before.value? <= 1 AND
1 <= after.value?
CREATE newValue={name:1,value : 1},
before-[:LINK]->newValue,
newValue-[:LINK]->after
DELETE old
==== zero ====
MATCH p = zero-[:LINK*1..]->zero
RETURN length(p) as list_length


我想做的是了解前后数据集和零数据集-我几乎拥有它,但想了解如何在具有两个以上起始点的集合中完成该操作节点,以消除任何混乱


What I'm trying to do in my mind is understand the before after and zero data sets - I almost have it, but want to see how it's done on a set with more than two starting nodes so as to clear up any confusion

谢谢!

推荐答案

前面的节点很特殊,因为它没有传入链接关系.通常,您还将连接到头节点的连接保留在某个位置,因此这是关于替换到头节点的链接,并将头节点进一步移动一步.像这样:

The node in front is special as it doesn't have a incoming link relationship. Usually you also keep the connection to the head node somewhere, so this is about replacing this link to the head node and moving the head node one step further away. Something like this:

start user=node:node_auto_index(user="me")
match user-[old:MESSAGES]->head
delete old
create new_heads = { title: "Title", date : 2348972389, text: "Text" },
 user-[:MESSAGES]->new_head-[:LINK]->head

这篇关于Neo4j链表-多个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆