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.

How to create a hierarchy of subgraphs/clusters?

I am unfamiliar with Neo4 and want to find out whether it is the right tool for me.

Is it possible to nest nodes in a hierarchy of subgraphs/clusters as in this GraphViz graph? If so, what would the Cypher query be to create that graph?

image.png

1 REPLY 1

You surely can create a representation of you nodes in neo4j. Neo4j does not have a 'cluster' concept to group a collection of nodes, but you can implement something to mimic the behavior. One suggestion is to add a label to all the nodes in a cluster with the cluster's name.  This would allow you to easily retrieve the nodes for a particular cluster, such as Cluster A1 and A2 in your diagram. You could create a node with the label cluster and create relationships from it to each of the root nodes of individual clusters to group clusters, such as Cluster A in your diagram. This would allow you to get the root nodes for each related cluster associated with a cluster group. You can then get the nodes from each cluster knowing their root node. 

Another approach that does not use labels would be to create 'cluster' nodes to and have those nodes related to the root of each cluster and/or to other cluster nodes to group clusters. 

As you can see, there are multiple ways to design a domain model. He is one example. From this, you can derive the nodes in each cluster A1 and A2, as well as the clusters comprising group A and all the entities within those clusters. 

Screen Shot 2022-12-31 at 1.06.53 PM.png