Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-11-2021 01:09 AM
Greetings,
I have the following question. Based on a similar graph (which for now we can safely assume is a tree). The relationships are one directional SPONSORS>
ones.
I find a difficulty understanding the difference between the following queries and why with larger sets of data they differ.
MATCH (p:User { userId: "3"})
CALL apoc.path.subgraphNodes(p, {
relationshipFilter: "SPONSORS>",
maxLevel: 3
})
YIELD node
RETURN node;
And the following query:
MATCH (p:User { userId: "3"})-[:SPONSORS*..3]->(child:User)
return child;
My issue arises from the fact that I cannot understand how the second query practically works, even after reading the related documentation here:
Neo4j match relationships with variable depth.
Ultimately, I am striving to find the way to optimally query every node "under"(since I'm practically using a Tree) a given node (i.e id = 3)
My expected results from both the queries would be to return nodes from 4 to 10 (disregarding order).
Thank you for the patience and I am sorry if anything is confusing, as this is my first post here :). All recommendations/advice are welcome
Solved! Go to Solution.
01-11-2021 03:37 AM
What are you getting instead
I would expect the same. It could be that it's just ..2
as you want 2 relationships down.
subgraphNodes might be more efficient as it also controls other things (you can also set bfs/dfs here depending on how you want to traverse)
01-11-2021 03:37 AM
What are you getting instead
I would expect the same. It could be that it's just ..2
as you want 2 relationships down.
subgraphNodes might be more efficient as it also controls other things (you can also set bfs/dfs here depending on how you want to traverse)
01-11-2021 05:38 AM
Greetings,
It seems I have had some issues with the data that I had been using.
After re-testing I see that it does actually provide the same data successfully. Thank you for the attention
All the sessions of the conference are now available online