src/main/java/org/thegalactic/lattice/ConceptLattice.java
public Vector<TreeSet<Comparable>> immediateSuccessors(Node n, ClosureSystem init) {
        // Initialisation of the dependance graph when not initialised by method recursiveDiagramLattice
        if (!this.hasDependencyGraph()) {
            ConcreteDGraph graph = new ConcreteDGraph();
            for (Comparable c : init.getSet()) {
                graph.addNode(new Node(c));
            }
            this.setDependencyGraph(graph);
        }
        // computes newVal, the subset to be used to valuate every new dependance relation
        // newVal = F\predecessors of F in the precedence graph of the closure system
        // For a non reduced closure system, the precedence graph is not acyclic,
        // and therefore strongly connected components have to be used.
        ComparableSet setF = new ComparableSet(((Concept) n).getSetA());
        ConcreteDGraph prec = init.precedenceGraph();
        DAGraph acyclPrec = prec.getStronglyConnectedComponent();
        ComparableSet newVal = new ComparableSet();
        newVal.addAll(setF);
        for (Object x : setF) {
            // computes nx, the strongly connected component containing x
            Node nx = null;
            for (Object cc : acyclPrec.getNodes()) {
                TreeSet<Node> setCC = (TreeSet<Node>) ((Node) cc).getContent();
                for (Node y : setCC) {
                    if (x.equals(y.getContent())) {
                        nx = (Node) cc;
                    }
                }
            }
            // computes the minorants of nx in the acyclic graph
            SortedSet<Node> ccMinNx = acyclPrec.minorants(nx);
            // removes from newVal every minorants of nx
            for (Node cc : ccMinNx) {
                TreeSet<Node> setCC = (TreeSet<Node>) cc.getContent();
                for (Node y : setCC) {
                    newVal.remove(y.getContent());
                }
            }
        }
        // computes the node belonging in S\F
        TreeSet<Node> nodes = new TreeSet<Node>();
        for (Object in : this.getDependencyGraph().getNodes()) {
            if (!setF.contains(((Node) in).getContent())) {
                nodes.add((Node) in);
            }
        }
        // computes the dependance relation between nodes in S\F
        // and valuated this relation by the subset of S\F
        TreeSet<Edge> edges = new TreeSet<Edge>();
        for (Node source : nodes) {
            for (Node target : nodes) {
                if (!source.equals(target)) {
                    // check if source is in dependance relation with target
                    // i.e. "source" belongs to the closure of "F+target"
                    ComparableSet fPlusTo = new ComparableSet(setF);
                    fPlusTo.add(target.getContent());
                    fPlusTo = new ComparableSet(init.closure(fPlusTo));
                    if (fPlusTo.contains(source.getContent())) {
                        // there is a dependance relation between source and target
                        // search for an existing edge between source and target
                        Edge ed = this.getDependencyGraph().getEdge(source, target);
                        if (ed == null) {
                            ed = new Edge(source, target, new TreeSet<ComparableSet>());
                            this.getDependencyGraph().addEdge(ed);
                        }
                        edges.add(ed);
                        // check if F is a minimal set closed for dependance relation between source and target
                        ((TreeSet<ComparableSet>) ed.getContent()).add(newVal);
                        TreeSet<ComparableSet> valEd = new TreeSet<ComparableSet>((TreeSet<ComparableSet>) ed.getContent());
                        for (ComparableSet x1 : valEd) {
                            if (x1.containsAll(newVal) && !newVal.containsAll(x1)) {
                                ((TreeSet<ComparableSet>) ed.getContent()).remove(x1);
                            }
                            if (!x1.containsAll(newVal) && newVal.containsAll(x1)) {
                                ((TreeSet<ComparableSet>) ed.getContent()).remove(newVal);
                            }
                        }
                    }
                }
            }
        }
        // computes the dependance subgraph of the closed set F as the reduction
        // of the dependance graph composed of nodes in S\A and edges of the dependance relation
        ConcreteDGraph sub = this.getDependencyGraph().getSubgraphByNodes(nodes);
        ConcreteDGraph delta = sub.getSubgraphByEdges(edges);
        // computes the sources of the CFC of the dependance subgraph
        // that corresponds to successors of the closed set F
        DAGraph cfc = delta.getStronglyConnectedComponent();
        SortedSet<Node> sccMin = cfc.getSinks();
        Vector<TreeSet<Comparable>> immSucc = new Vector<TreeSet<Comparable>>();
        for (Node n1 : sccMin) {
            TreeSet s = new TreeSet(setF);
            TreeSet<Node> toadd = (TreeSet<Node>) n1.getContent();
            for (Node n2 : toadd) {
                s.add(n2.getContent());
            }
            immSucc.add(s);
        }
        return immSucc;
    }
/**
     * Returns the list of immediate successors of a given node of the lattice.
     *
     * This treatment is an adaptation of Bordat's theorem stating that there is
     * a bijection between minimal strongly connected component of the
     * precedence subgraph issued from the specified node, and its immediate
     * successors.
     *
     * This treatment is performed in O(Cl|S|^3log g) where S is the initial set
     * of elements, Cl is the closure computation complexity and g is the number
     * of minimal generators of the lattice.
     *
     * This treatment is recursively invoked by method recursiveDiagramlattice.
     * In this case, the dependance graph is initialised by method
     * recursiveDiagramMethod, and updated by this method, with addition some
     * news edges and/or new valuations on existing edges. When this treatment
     * is not invoked by method recursiveDiagramLattice, then the dependance
     * graph is initialised, but it may be not complete. It is the case for
     * example for on-line generation of the concept lattice.
     *
     * @param n    a node
     * @param init a closure system
     *
     * @return a set of immediate successors
     */
Returns the list of immediate successors of a given node of the lattice.
This treatment is an adaptation of Bordat's theorem stating that there is
a bijection between minimal strongly connected component of the
precedence subgraph issued from the specified node, and its immediate
successors.

This treatment is performed in O(Cl|S|^3log g) where S is the initial set
of elements, Cl is the closure computation complexity and g is the number
of minimal generators of the lattice.

This treatment is recursively invoked by method recursiveDiagramlattice.
In this case, the dependance graph is initialised by method
recursiveDiagramMethod, and updated by this method, with addition some
news edges and/or new valuations on existing edges. When this treatment
is not invoked by method recursiveDiagramLattice, then the dependance
graph is initialised, but it may be not complete. It is the case for
example for on-line generation of the concept lattice.

@param n    a node
@param init a closure system

@return a set of immediate successors
Returns the list of immediate successors of a given node of the lattice . This treatment is an adaptation of Bordat ' s theorem stating that there is a bijection between minimal strongly connected component of the precedence subgraph issued from the specified node and its immediate successors . This treatment is performed in O ( Cl|S|^3log g ) where S is the initial set of elements Cl is the closure computation complexity and g is the number of minimal generators of the lattice . This treatment is recursively invoked by method recursiveDiagramlattice . In this case the dependance graph is initialised by method recursiveDiagramMethod and updated by this method with addition some news edges and / or new valuations on existing edges . When this treatment is not invoked by method recursiveDiagramLattice then the dependance graph is initialised but it may be not complete . It is the case for example for on - line generation of the concept lattice . @param n a node @param init a closure system @return a set of immediate successors
public Vector<TreeSet<Comparable>> immediateSuccessors(Node n, ClosureSystem init) {
        if (!this.hasDependencyGraph()) {
            ConcreteDGraph graph = new ConcreteDGraph();
            for (Comparable c : init.getSet()) {
                graph.addNode(new Node(c));
            }
            this.setDependencyGraph(graph);
        }
        ComparableSet setF = new ComparableSet(((Concept) n).getSetA());
        ConcreteDGraph prec = init.precedenceGraph();
        DAGraph acyclPrec = prec.getStronglyConnectedComponent();
        ComparableSet newVal = new ComparableSet();
        newVal.addAll(setF);
        for (Object x : setF) {
            Node nx = null;
            for (Object cc : acyclPrec.getNodes()) {
                TreeSet<Node> setCC = (TreeSet<Node>) ((Node) cc).getContent();
                for (Node y : setCC) {
                    if (x.equals(y.getContent())) {
                        nx = (Node) cc;
                    }
                }
            }
            SortedSet<Node> ccMinNx = acyclPrec.minorants(nx);
            for (Node cc : ccMinNx) {
                TreeSet<Node> setCC = (TreeSet<Node>) cc.getContent();
                for (Node y : setCC) {
                    newVal.remove(y.getContent());
                }
            }
        }
        TreeSet<Node> nodes = new TreeSet<Node>();
        for (Object in : this.getDependencyGraph().getNodes()) {
            if (!setF.contains(((Node) in).getContent())) {
                nodes.add((Node) in);
            }
        }
        TreeSet<Edge> edges = new TreeSet<Edge>();
        for (Node source : nodes) {
            for (Node target : nodes) {
                if (!source.equals(target)) {
                    ComparableSet fPlusTo = new ComparableSet(setF);
                    fPlusTo.add(target.getContent());
                    fPlusTo = new ComparableSet(init.closure(fPlusTo));
                    if (fPlusTo.contains(source.getContent())) {
                        Edge ed = this.getDependencyGraph().getEdge(source, target);
                        if (ed == null) {
                            ed = new Edge(source, target, new TreeSet<ComparableSet>());
                            this.getDependencyGraph().addEdge(ed);
                        }
                        edges.add(ed);
                        ((TreeSet<ComparableSet>) ed.getContent()).add(newVal);
                        TreeSet<ComparableSet> valEd = new TreeSet<ComparableSet>((TreeSet<ComparableSet>) ed.getContent());
                        for (ComparableSet x1 : valEd) {
                            if (x1.containsAll(newVal) && !newVal.containsAll(x1)) {
                                ((TreeSet<ComparableSet>) ed.getContent()).remove(x1);
                            }
                            if (!x1.containsAll(newVal) && newVal.containsAll(x1)) {
                                ((TreeSet<ComparableSet>) ed.getContent()).remove(newVal);
                            }
                        }
                    }
                }
            }
        }
        ConcreteDGraph sub = this.getDependencyGraph().getSubgraphByNodes(nodes);
        ConcreteDGraph delta = sub.getSubgraphByEdges(edges);
        DAGraph cfc = delta.getStronglyConnectedComponent();
        SortedSet<Node> sccMin = cfc.getSinks();
        Vector<TreeSet<Comparable>> immSucc = new Vector<TreeSet<Comparable>>();
        for (Node n1 : sccMin) {
            TreeSet s = new TreeSet(setF);
            TreeSet<Node> toadd = (TreeSet<Node>) n1.getContent();
            for (Node n2 : toadd) {
                s.add(n2.getContent());
            }
            immSucc.add(s);
        }
        return immSucc;
    }
public Vector < TreeSet < Comparable > > immediateSuccessors ( Node n , ClosureSystem init ) { if ( ! this . hasDependencyGraph ( ) ) { ConcreteDGraph graph = new ConcreteDGraph ( ) ; for ( Comparable c : init . getSet ( ) ) { graph . addNode ( new Node ( c ) ) ; } this . setDependencyGraph ( graph ) ; } ComparableSet setF = new ComparableSet ( ( ( Concept ) n ) . getSetA ( ) ) ; ConcreteDGraph prec = init . precedenceGraph ( ) ; DAGraph acyclPrec = prec . getStronglyConnectedComponent ( ) ; ComparableSet newVal = new ComparableSet ( ) ; newVal . addAll ( setF ) ; for ( Object x : setF ) { Node nx = null ; for ( Object cc : acyclPrec . getNodes ( ) ) { TreeSet < Node > setCC = ( TreeSet < Node > ) ( ( Node ) cc ) . getContent ( ) ; for ( Node y : setCC ) { if ( x . equals ( y . getContent ( ) ) ) { nx = ( Node ) cc ; } } } SortedSet < Node > ccMinNx = acyclPrec . minorants ( nx ) ; for ( Node cc : ccMinNx ) { TreeSet < Node > setCC = ( TreeSet < Node > ) cc . getContent ( ) ; for ( Node y : setCC ) { newVal . remove ( y . getContent ( ) ) ; } } } TreeSet < Node > nodes = new TreeSet < Node > ( ) ; for ( Object in : this . getDependencyGraph ( ) . getNodes ( ) ) { if ( ! setF . contains ( ( ( Node ) in ) . getContent ( ) ) ) { nodes . add ( ( Node ) in ) ; } } TreeSet < Edge > edges = new TreeSet < Edge > ( ) ; for ( Node source : nodes ) { for ( Node target : nodes ) { if ( ! source . equals ( target ) ) { ComparableSet fPlusTo = new ComparableSet ( setF ) ; fPlusTo . add ( target . getContent ( ) ) ; fPlusTo = new ComparableSet ( init . closure ( fPlusTo ) ) ; if ( fPlusTo . contains ( source . getContent ( ) ) ) { Edge ed = this . getDependencyGraph ( ) . getEdge ( source , target ) ; if ( ed == null ) { ed = new Edge ( source , target , new TreeSet < ComparableSet > ( ) ) ; this . getDependencyGraph ( ) . addEdge ( ed ) ; } edges . add ( ed ) ; ( ( TreeSet < ComparableSet > ) ed . getContent ( ) ) . add ( newVal ) ; TreeSet < ComparableSet > valEd = new TreeSet < ComparableSet > ( ( TreeSet < ComparableSet > ) ed . getContent ( ) ) ; for ( ComparableSet x1 : valEd ) { if ( x1 . containsAll ( newVal ) && ! newVal . containsAll ( x1 ) ) { ( ( TreeSet < ComparableSet > ) ed . getContent ( ) ) . remove ( x1 ) ; } if ( ! x1 . containsAll ( newVal ) && newVal . containsAll ( x1 ) ) { ( ( TreeSet < ComparableSet > ) ed . getContent ( ) ) . remove ( newVal ) ; } } } } } } ConcreteDGraph sub = this . getDependencyGraph ( ) . getSubgraphByNodes ( nodes ) ; ConcreteDGraph delta = sub . getSubgraphByEdges ( edges ) ; DAGraph cfc = delta . getStronglyConnectedComponent ( ) ; SortedSet < Node > sccMin = cfc . getSinks ( ) ; Vector < TreeSet < Comparable > > immSucc = new Vector < TreeSet < Comparable > > ( ) ; for ( Node n1 : sccMin ) { TreeSet s = new TreeSet ( setF ) ; TreeSet < Node > toadd = ( TreeSet < Node > ) n1 . getContent ( ) ; for ( Node n2 : toadd ) { s . add ( n2 . getContent ( ) ) ; } immSucc . add ( s ) ; } return immSucc ; }
Returns the list of immediate successors of a given node of the lattice.
Returns the list of immediate successors of a given node of the lattice .
// Initialisation of the dependance graph when not initialised by method recursiveDiagramLattice // computes newVal, the subset to be used to valuate every new dependance relation // newVal = F\predecessors of F in the precedence graph of the closure system // For a non reduced closure system, the precedence graph is not acyclic, // and therefore strongly connected components have to be used. // computes nx, the strongly connected component containing x // computes the minorants of nx in the acyclic graph // removes from newVal every minorants of nx // computes the node belonging in S\F // computes the dependance relation between nodes in S\F // and valuated this relation by the subset of S\F // check if source is in dependance relation with target // i.e. "source" belongs to the closure of "F+target" // there is a dependance relation between source and target // search for an existing edge between source and target // check if F is a minimal set closed for dependance relation between source and target // computes the dependance subgraph of the closed set F as the reduction // of the dependance graph composed of nodes in S\A and edges of the dependance relation // computes the sources of the CFC of the dependance subgraph // that corresponds to successors of the closed set F