Virtual Nodes & Relationships (Graph Projections)
Virtual Nodes and Relationships do not 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.
Working with Virtual Nodes
Virtual Nodes cannot be queried from the graph as they must be kept in a local lookup structure.
This means that some built-in Cypher functions may not work.
For example, using the /docs/cypher-manual/5/functions/list/#functions-labels[labels()
^] function on a Virtual Node or Relationship will return an empty list []
.
APOC provides functions that facilitate working with Virtual Nodes and Relationships.
Qualified Name | Type |
---|---|
apoc.any.properties |
|
apoc.any.property |
|
apoc.map.groupBy |
|
apoc.node.id |
|
apoc.node.labels |
|
apoc.rel.endNode
|
|
apoc.rel.id
|
|
apoc.rel.startNode
|
|
apoc.rel.type
|
|
Virtual Nodes and Relationships have negative ids. |
Virtual entities also have the following use cases:
-
Return only selected properties of nodes/relationships to the visualization (e.g. remove large or sensitive 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
For more information on how to use these procedures, see: