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
答案 0 :(得分:2)
根据this comment在neo4j的Github的一个公开问题中,这是不可能的。
正如InverseFalcon在此评论中所述,您可以使用APOC Procedures来实现此目标,如Mark Needham博客的this post中所述。
拳头,安装Apoc程序。在此之后,例如:
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