liveBook · Manning

Relationship direction

As explained in Graph Algorithms for Data Science

Relationship direction is the orientation of a graph relationship from its start node to its end node.

Relationship direction records how a graph relationship points from its start node to its end node. Whether that direction carries meaning depends on the relationship, so schema diagrams may require careful interpretation. section 2.3.4

Graph projection can preserve, reverse, or disregard stored relationship orientation:

  • NATURAL projects each relationship as stored in the database. section 7.2.2
  • REVERSE projects each relationship in the opposite direction. section 7.2.2
  • UNDIRECTED projects both natural and reverse orientations; the engine duplicates the relationship in the opposite direction. section 7.2.2

Reverse HAS_TAG relationships for similarity analysis

A hashtag co-occurrence task projects Tweet and Tag nodes while reversing HAS_TAG relationships. The projected relationship is exposed under the REVERSED_HAS_TAG alias, allowing node similarity to compare hashtags through their associated tweets. section 7.2.2

Listing 7.10 Configuration map to describe the relationship type and its orientation
{ALIAS_OF_TYPE: {type:'RELATIONSHIP_TYPE',
                orientation: 'NATURAL',
                properties:['property1','property2']}

Inspect the configuration-map structure for naming a projected relationship, selecting its stored type, choosing orientation, and optionally selecting properties. section 7.2.2

Listing 7.11 Projects Tweet and Tag nodes and includes reversed HAS_TAG relationships
CALL gds.graph.project(
    'tags',                                                        #1
   ['Tweet', 'Tag'],                                               #2
   {REVERSED_HAS_TAG: {orientation:'REVERSE', type:'HAS_TAG'}});   #3

Inspect an executable projection that includes Tweet and Tag nodes and reverses HAS_TAG relationships. section 7.2.2

How Graph Algorithms for Data Science covers it

How deep it goes
Defines start and end orientation, explains three projection modes, and stops short of formal graph-theory treatment.
Examples
Demonstrates FOLLOWS and RETWEETS schema relationships plus reversed HAS_TAG projection for hashtag co-occurrence.
What it assumes
Assumes basic nodes and relationships, while introducing projection aliases, orientation values, and semantic direction.
What you can do after
Apply it via Cypher and Graph Data Science projection configuration to preserve, reverse, or treat relationships as undirected.
How it connects
Connects relationship direction with graph schemas, self-loops, graph projection, in-memory graphs, and node similarity.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Graph Algorithms for Data Science. The section links point to the parts of the book it draws on.