Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-04-2020 03:18 AM
Hi!
I have the following problem:
I have a graph (duh 😉 ) and given a set of nodes say, N1, N2, N3,.. I want to find the subgraph containing N1, N2,.. and all the elements that are between them.. so if A is an element of the subgraph there should be a path in the subgraph between A and each Ni.
I have tried some approaches to do this, but none has been a total succes.
The best one has been to call apoc.path.subgraphNodes for Ni, with some maxLevel, and then done an intersection between all the result and then done a apoc.path.expandConfig with the common nodes as start and end nodes.
This gives me the subgraph, but also a lot of extra nodes and relationships;
if, say, N1 and N2 are one step away from eachother and I call subgraphNodes with maxLevel I will get a lot of nodes in the intersection that are not between the nodes, but "on the side".
Does anyone have a good approach for making this query?
Been thinking about using apoc.spanningTree instead, but that wouldnt give me all the nodes between the given nodes, but some subset of them..
Ive also thought about setting the stop nodes for subgraphNodes, but I cant put all the Ni there, because everything stops at once and nothing is returned.. and to make a new list for each call to subgraphNodes seems like a hassle..
Thanks
All the sessions of the conference are now available online