Chapter 15. Virtual Nodes & Relationships (Graph Projections)

This chapter describes virtual node and relationship procedures in the APOC library.

Virtual Nodes and Relationships don’t exist in the graph, they are only returned by a query, and can be used to represent a graph projection.

They can be used to visually project data, for example aggregating relationships into one, or collapsing intermediate nodes into virtual relationships. We could project a citation graph into a virtual author-author or paper-paper graph with aggregated relationships between them, or even turn Twitter data into a user-user mention graph.

We can combine real and virtual entities, for example by creating a virtual relationship between two real nodes or creating a virtual relationship from a virtual node to a real node.

Below are some other uses of virtual entities:

There are a few things to keep in mind when using virtual nodes:

  • They have negative ids.
  • As virtual nodes cannot be queried from the graph, they must be kept in our own lookup structure. The apoc.map.groupBy function works well for this.

For more information on how to use these procedures, see: