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.

Find all nodes and edges connecting a set of nodes

I am trying to retrieve all the nodes and edges (edges can be optional if it improves performance) that connect a set of nodes n, m, x, and y

I know the connectivity in advance:
(n)-[]->(m)-[]->(x)
(y)-[*]->(x)

What would be the most efficient way to gather all the nodes (without duplicates)?

What I have tried:

  • apoc.path.expandConfig
  • allShortestPaths
  • regular path matching

What I have found is that I can only get a decent performance with apoc.path.expandConfig, searching for other approaches (that I might have missed).

5 REPLIES 5

intouch_vivek
Graph Steward

Hi,

If you just need to find distinct nodes then try
Match(n) return distinct n

@intouch.vivek The graph is much-much larger, I am only interested in a subgraph between a set of nodes

Should subgraphNodes and expandConfig return the same result/nodes if used with the same uniqueness setting?

For that you need to do a POC as haven't used expandConfig