Search code examples
springgrailsgraphgrails-ormgrails-2.0

Check if Direct Acyclic Graph has no Cycle?


Assume I have the following directed graph structure:

class GraphNode {
    static hasMany = [children: GraphNode]
    static hasMany = [parents: GraphNode]
    static mappedBy = [children: 'parents', parents: 'children']
}

How can I restrict cycles?


Solution

  • Here an algorithm for that purpose: http://adhockery.blogspot.de/2010/06/acyclic-relationship-validation-in.html