neo4j创建相反的边缘 [英] neo4j create the opposite edge

查看:98
本文介绍了neo4j创建相反的边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是neo4j和cypher的新手,我需要创建图形所有边缘的对立面,但我需要对立面边缘具有与原始边缘相同的类型
为了说明起见,(a)-[:sometype]->(b)的反义词是(b)-[:sometype]->(a)
我知道通过点击此命令来创建所有边缘的对立面非常容易 match (a)-[]->(b) create (b)-[]->(a)
但是正如我已经说过的,我需要创建的边具有与原始边相同的类型 谢谢

i am new to neo4j and cypher , i need to create the opposite of all the edges of the graph but i need that the opposites edges to have the same type of the original edges
for illustration the opposite of (a)-[:sometype]->(b) would be (b)-[:sometype]->(a)
i know that it is very easy to create the opposite of all the edges by just tapping this command match (a)-[]->(b) create (b)-[]->(a)
but as i have already said i need the created edge to have the same type of the original edge thank you

推荐答案

根据此评论在neo4j的Github中尚待解决,这还不可能.

According to this comment in an open question in neo4j's Github this is not possible yet.

正如InverseFalcon在此评论中所说,您可以使用 APOC程序达到此内容中所述的目标Mark Needham博客中发布.

As said by InverseFalcon in this comment, you can use APOC Procedures to achieve this goal as described in this post from Mark Needham blog.

首先,安装Apoc Procedures.之后,例如:

Fist, install Apoc Procedures. After this, e.g.:

CREATE (a)-[:sometype]->(b)

//Match...
MATCH (a)-[r]->(b)
WITH r, a, b
// and use apoc.create.relationship to achieve your goal...
CALL apoc.create.relationship(b, TYPE(r), {}, a) YIELD rel
RETURN rel

在这里进行了测试:

这篇关于neo4j创建相反的边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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