fatnjazzy
fatnjazzy

Reputation: 6152

Cypher query - only one direction result

I have the graph at the bottom.
I want to bring all the connections between GraphTarget that the FriendOf is not b-directional.
Everything inside the red zone, (max 5 levels of FriendOf)

http://console.neo4j.org/r/pb9mp - a place to play with the query

enter image description here

Upvotes: 2

Views: 161

Answers (1)

Filippo Grazioli
Filippo Grazioli

Reputation: 385

I hope this can help you a bit:

MATCH (gt:GraphTarget)
MATCH path_account = (:Account)-[:FriendOf*]->(:Account)
MATCH (account1:Account)-[:FriendOf]->(account2:Account)
MATCH (account2:Account)-[:FriendOf]->(account1:Account)
WHERE none(node IN nodes(path_account) WHERE node=account1 OR node=account2)
RETURN gt, nodes(path_account)

I checked it graphically in Neo4j and this is the result:

Your graph Your graph

The query Your query

Upvotes: 2

Related Questions