cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

subgraphAll problem

kaptenh
Node Clone

Hi!
I have the following scenario: I have a bunch of nodes and I want to find all paths between them with certain conditions. I am thinking I should be able to use apoc.subgraphAll to do so, and use the same list of nodes as startnodes and endNodes. But I get nothing back.
I tried the following:
match (a:Alabel {id: 1}), (b:Alabel {id: 2})
call apoc.path.subgraphAll(a, {minLevel: 1, maxLevel: 3, endNodes: [a,b]})

I get one path which is expected. As I have a list of possible nodes to start with and subgraphAll accepts a list as startNodes I figured I should be able to do:
match (a:Alabel {id: 1}), (b:Alabel {id: 2})
call apoc.path.subgraphAll([a,b], {minLevel: 1, maxLevel: 3, endNodes: [a,b]})

and still get the same result, but I get nothing.
In reality I want to match a couple of hundred nodes and add nodeFilters and labelFilters..
Why doesnt the subgraphAll query above give me the paths between a and b?

Thanks..

1 REPLY 1

Keep in mind that your use case here probably isn't a good fit for this procedure:

I have a bunch of nodes and I want to find all paths between them with certain conditions

subgraphAll() is about first expanding to all reachable nodes (given the filters), and then for that set of nodes, finding the relationships (but not paths) that connect to other nodes in the same set.

Finding all paths between nodes with certain conditions sounds more suited to regular Cypher querying.

This procedure is also one of several related procedures that uses NODE_GLOBAL uniqueness, meaning once a node is visited, it cannot be visited again, and that makes it a poor fit for your use case, since as you start with both of them, they are now both visited, so no other paths to them will be considered.