0
votes

I'm using neo4j and I build a large graph that has a lot of subgraph. For example, in the pic below there are 4 subgraphs. enter image description here

So how can I get 4 groups of nodes by cypher query?

I'm using neo4j 3.0

2

2 Answers

1
votes

You can make use of Strongly connected components algorithm in the Graph data science library (GDS - https://github.com/neo4j/graph-data-science) for Neo4j. The documentation is available at - https://neo4j.com/docs/graph-data-science/current/algorithms/strongly-connected-components/ You can create a sub-graph using node projection or other methods are available in the docs and as the name suggests, the algorithm will create separate communities in your graph, by using strongly connected component logic (https://en.wikipedia.org/wiki/Strongly_connected_component), and you will have nodes separated out like you want.

-1
votes

If you want to display all node along with all relationships, you can use a quick and easy cypher query at your disposal. Assuming there are no restrictions applicable to your account:

MATCH (n) RETURN n