Prevent creating a relationship if it will create a cycle

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?

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

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 :slight_smile:

Am I missing something or is that helpful?