cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Prevent creating a relationship if it will create a cycle

li3zhang
Node Link

When creating an app like a family tree, I want to prevent the user from creating relationships that will create a cycle. Is it possible to tell if a transaction will create a cycle before committing?

1 REPLY 1

llpree
Graph Buddy

li3zhang, welcome to the community! Love the question as I love graph theory

Given a family tree is a directed graph (i.e., a father of a son is not a son to a father for the same two nodes), getting a cycle will be impossible. Certainly, someone's cousin can be another persons brother and this can result in a "cycle" if you ignore direction and relationship type. But I would contend that finding cycles by ignoring relationship type and direction would be very useful and desired in terms of insights in your tree - especially before the royal wedding

Am I missing something or is that helpful?

HTH