cancel
Showing results for 
Search instead for 
Did you mean: 

Combine multiple paths into one in neo4j

I would like to combine paths from multiple match query. Consider a query

MATCH path_1 =  (t1:Type1)-[r1:]->(t2:Type2)
MATCH path_2 =  (t2)-[r2]->(t3:Type3) 
MATCH path_3 =  (t1)-[r3]->(t4:Type4)
RETURN path_1,path_2,path_3
  1. How to combine all these three paths into one as like apoc.path.combine(path_1,path_2) as path , But it just combines two paths. I want to combine more than three paths.
  2. How does Neo4j browser able to render a graph with the output given by above query? I can use the same logic to generate paths
2 REPLIES 2

ameyasoft
Graph Maven
With apoc.path.combine(path_1,path_2)  as path12
WITH apoc.path.combine(path12, path_3) as path
RETURN path

clem
Graph Steward

I don't understand what you are trying to do. If t2,t3,t4 are distinctly different nodes then you are in trouble.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online