apoc.meta.graph.of(graph ANY, config MAP<STRING, ANY>) - examines the given sub-graph and returns a meta-graph.

This procedure returns virtual nodes and relationships that can only be accessed by other APOC procedures. For more information, see Virtual Nodes & Relationships (Graph Projections).

This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime (introduced in Neo4j 5.13). For more information, see the Cypher Manual → Parallel runtime.


apoc.meta.graph.of(graph = {} :: ANY, config = {} :: MAP) :: (nodes :: LIST<NODE>, relationships :: LIST<RELATIONSHIP>)

Input parameters

Name Type Default







Config parameters

The procedure supports the following config parameters:

Table 1. Config parameters
Name Type Default Description




Number of nodes whose relationships are checked to remove false positives. See "Sampling" section below.




number of relationships to be analyzed, by type of relationship and start and end label, in order to remove/add relationships incorrectly inserted / not inserted by the sample result.




number of relationships to sample per relationship type.


This procedure works by using the database statistics. A new node is returned for each label, and its connecting relationships are calculated based on the pairing combinations of [:R]→(:N) and (:M)→[:R]. For example, for the graph (:A)-[:R]→(:B)-[:R]→(:C), the path (:B)-[:R]→(:B) will be calculated from the combination of [:R]→(:B) and (:B)-[:R]. This procedure will post-process the data by default, removing all non-existing relationships. This is done by scanning the nodes and their relationships. If the relationship is not found, it is removed from the final result. This slows down the procedure, but will produce an accurate schema.

See apoc.meta.graphSample to avoid performing any post-processing.

It is also possible to specify how many nodes and relationships to scan. The config parameter sample gives the skip count, and the maxRels parameter gives the max number of relationships that will be checked per node. If sample is set to 100, this means that every 100th node will be checked per label, and a value of 100 for maxRels means that for each node read, only the first 100 relationships will be read. Note that if these values are set, and the relationship is not found within those constraints, it is assumed that the relationship does not exist, and this may result in false negatives.

A sample value higher than the number of nodes for that label will result in one node being checked.

Output parameters

Name Type





Usage Examples

Type of supported input graphs

Type Description


a Cypher query

Virtual Graph

a Virtual Graph returned by apoc.graph.*


a map with two field nodes (a list of nodes, mandatory), relationships (a list of relationships)

If you have a quite complex Graph, and you want to analyze and get some info about a specific sub-graph in it, you can leverage the apoc.meta.graph.of procedure.

So for the given Graph Model:


You can leverage the apoc.meta.graph.of procedure in this way:


That will extract the Meta Graph of the provided query, with some stats like the count for each node involved into the query.

If you want more details you can also look at apoc.meta.graph documentation