protected final Vertex addIntent ( final E proposed , Vertex generator ) { generator = supremum ( proposed , generator ) ; if ( filter ( generator , proposed ) && filter ( proposed , generator ) ) { return generator ; } List parents = new ArrayList <> ( ) ; for ( Edge edge : generator . getEdges ( Direction . BOTH ) ) { Vertex target = edge . getVertex ( Direction . OUT ) ; if ( filter ( target , generator ) ) { continue ; } Vertex candidate = target ; if ( ! filter ( target , proposed ) && ! filter ( proposed , target ) ) { E targetElement = target . getProperty ( LABEL ) ; E intersect = ( E ) targetElement . intersect ( proposed ) ; candidate = addIntent ( intersect , candidate ) ; } boolean add = true ; List doomed = new ArrayList <> ( ) ; for ( java . util . Iterator it = parents . iterator ( ) ; it . hasNext ( ) ; ) { Vertex parent = ( Vertex ) it . next ( ) ; if ( filter ( parent , candidate ) ) { add = false ; break ; } else if ( filter ( candidate , parent ) ) { doomed . add ( parent ) ; } } for ( java . util . Iterator it = doomed . iterator ( ) ; it . hasNext ( ) ; ) { Vertex vertex = ( Vertex ) it . next ( ) ; parents . remove ( vertex ) ; } if ( add ) { parents . add ( candidate ) ; } } E generatorLabel = generator . getProperty ( LABEL ) ; Vertex child = insert ( ( E ) proposed . union ( generatorLabel ) ) ; addUndirectedEdge ( generator , child , "" ) ; bottom = filter ( bottom , proposed ) ? child : bottom ; for ( java . util . Iterator it = parents . iterator ( ) ; it . hasNext ( ) ; ) { Vertex parent = ( Vertex ) it . next ( ) ; if ( ! parent . equals ( generator ) ) { removeUndirectedEdge ( parent , generator ) ; addUndirectedEdge ( parent , child , "" ) ; } } return child ; }
Add a new element dynamically to the lattice .