Virtual Nodes & Relationships (Graph Projections)

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:

  • return only a few properties of nodes/rels to the visualization, e.g. if you have huge text properties

  • visualize clusters found by graph algorithms

  • aggregate information to a higher level of abstraction

  • skip intermediate nodes in a longer path

  • hide away properties or intermediate nodes/relationships for security reasons

  • graph grouping

  • visualization of data from other sources (computation, RDBMS, document-dbs, CSV, XML, JSON) as graph without even storing it

  • projecting partial data

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: