-
Notifications
You must be signed in to change notification settings - Fork 156
Open
Labels
Description
CIR-2017-172
Related to #173
I want to be able to model a DAG (Directed Acyclic Graph) in cypher. So I need to be able to ensure that when a relationship is created then it doesn't create a loop.
I guess it could be done by remembering to code all the creates in a transaction, something like
# start transaction
match (a:T {key:'val1'}), (b:T {key:'val2'}) create (a)-[:R]->(b)
match p = (a:T {key:'val1'})-[:R*]-(a) return p limit 1
# abort transaction if there's now a loop
But that feels really clumsy and prone to developer errors. NB. see also neo4j/neo4j#8667
It would be much nicer to be able to say something like
create constraint on ()-[r:R]-() assert acyclic(r)
and have match (a:T {key:'val1'}), (b:T {key:'val2'}) create (a)-[:R]->(b) throw an error automatically if it would make a loop.