5.5. Multirelational (social) graphs

5.5.1. Who FOLLOWS or LOVES me back

Graph

cypher-multirelationalsocialnetwork-graph.svg

5.5.1. Who FOLLOWS or LOVES me back

This example shows a multi-relational network between persons and things they like. A multi-relational graph is a graph with more than one kind of relationship between nodes.

Query

START me=node:node_auto_index(name = 'Joe')
MATCH me-[r1]->other-[r2]->me
WHERE type(r1)=type(r2) AND type(r1) =~ /FOLLOWS|LOVES/
RETURN other.name, type(r1)

People that FOLLOWS or LOVES Joe back.

Result

other.nametype(r1)
3 rows, 1 ms

"Sara"

"FOLLOWS"

"Maria"

"FOLLOWS"

"Maria"

"LOVES"