【发布时间】:2020-10-14 10:29:32
【问题描述】:
1.我创建了 Tweet 和 TweetLeaf 节点,然后使用以下代码创建现实
MERGE (n:Tweet {id:'13084664', title:'A'})
MERGE (cl1:TweetLeaf {id:'13085170', title:'AB', reply_to:'13084664'})
MERGE (cl2:TweetLeaf {id:'13085179', title:'TESTING Team', reply_to:'13085170'})
MERGE (cl2:TweetLeaf {id:'13085352', title:'TESTING Team', reply_to:'13085170'})
MERGE (cl4:TweetLeaf {id:'13085443', title:'TESTING Team', retweet_to:'13085352'})
MERGE (cl5:TweetLeaf {id:'13085356', title:'TESTING Team', retweet_to:'13085352'})
//parent and leaf.....
MATCH (parent:Tweet)
MATCH (c:TweetLeaf)
WHERE NOT (c)-[:reply]->()
AND parent.id = c.reply_to
WITH parent, c
MERGE (c)-[:reply_to]->(parent)
//RETURN c, parent
//leaf to leaf reply_to.....
MATCH (c1:TweetLeaf)-[]-()
WHERE exists (c1.reply_to)
MATCH (d1:TweetLeaf)
WHERE NOT (d1)-[]->() and exists (d1.reply_to)
AND c1.id = d1.reply_to
WITH c1, d1
MERGE (d1)-[:reply_to]->(c1)
//RETURN c1, d1
//leaf to leaf retweet_to....
MATCH (c2:TweetLeaf)
WHERE exists (c2.retweet_to)
AND NOT (c2)-[]->()
MATCH (d2:TweetLeaf)-[]->()
WHERE d2.id = c2.retweet_to
WITH c2, d2
MERGE (c2)-[:retweet_to]->(d2)
//RETURN c2, d2
【问题讨论】:
-
您的代码对我来说运行良好。您是如何创建输出图的?
-
代码完全相同