Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-10-2022 06:35 AM
Our problem:
Given a one start point (node) or more (nodes) we want to create a directed tree (hierarchical) graph in Neo4j
. We have the restriction that all directions are always one-way. Further we know what nodes are connected, but we don't know the end nodes.
We are looking for an algorithm which can find inside graph in a way that given the start point all end points can be reached.
02-10-2022 09:05 AM
Try something like this to get the end nodes from a starting node:
match(n:Test{key:1})-[:REL*]-(m)
match p = (m)-[:REL]-()
with m, size (collect(p)) as noOfRelationships
where noOfRelationships = 1
return m as endNodes
02-10-2022 02:03 PM
You could probably also use breadth first search, depth first search, or - if you wanted to be fancy - single source shortest path - Dijkstra Single-Source - Neo4j Graph Data Science
All the sessions of the conference are now available online