Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-19-2019 05:11 AM
Hi,
Neo4j - 3.5.12
In my project I need to find different paths. I have nodes in my graph database like below
G has more than 1 relationship, so
[E,F,G] hop=2
[H,G] hop=1
X has 3 relationship, so
[A,B,X] hop=2
[C,D,X] hop=2
[E,F,G,X] hop=3
and in the above collection, G has 2 relationship
so
[H,G,X] hop=2
and so on.
I haven't used any apoc procedure.
Appreciate your advance help.
11-26-2019 10:42 AM
Hi,
Perhaps you can use something like this:
match (target)
where size(()-->(target)) > 1
match p=((a)-[*..5]->(target))
with target, collect(distinct nodes(p)) as nodes
return *
You probably want to limit the length of the paths. In the query above, the limit is 5.
If you only care about paths that start from nodes with no incoming edge, you can use the query below:
match (source) where not ()-->(source)
with collect(distinct source) as sources
match (target)
where size(()-->(target)) > 1
unwind sources as source
match p=((source)-[*..5]->(target))
with target, collect(distinct nodes(p)) as nodes
return *
Cheers,
Seyed
All the sessions of the conference are now available online