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

查看:21
本文介绍了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..

我使用了来自 grepcode 并发现它比 Neo4j 手册中的示例更有帮助.但是我还是有点困惑..有人可以修改它说在链表中有七个节点的七个节点,然后在它的前面插入一个节点吗?

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?

是的,我正在尝试将最新的状态更新放在链接列表的顶部.这个例子并没有真正做到这一点,但它很接近..所以寻找一些mods..不,我还没有真正编码,仍然试图首先掌握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天全站免登陆