Beispiel #1
0
 public FcaTree()
 {
     descendants = new List<FcaTree>();
     parent = null;
     mainSet = new FcaObjectSet();
     nextId = -1;
     listOfNodes = new List<FcaTree>();
     listOfSets = new List<FcaObjectSet>();
 }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            FcaMatrix matrix = new FcaMatrix();
            FileScanner fscan = new FileScanner();
            String[] processingFiles = Directory.GetFiles(txtSourceDir.Text);

            matrix = fscan.processFiles(processingFiles);

            FcaTree tree = new FcaTree();
            tree.closureOneByOne(matrix,tree);
            FcaObjectSet lattice = new FcaObjectSet();
            lattice.buildLattice(tree, matrix);
            fscan.RefactorHierarchy(lattice);
        }
Beispiel #3
0
        public FcaTree findInList(FcaObjectSet set)
        {
            FcaTree tr = new FcaTree();

            foreach (FcaTree t in listOfNodes)
            {
                if (t.getMainSet().Equals(set))
                {
                    tr = t;
                    break;
                }
            }
            //while ((tree.parent != null) && (!flag))
            //{
            //    foreach (FcaTree node in tree.descendants)
            //    {
            //        FcaObjectSet s = node.getMainSet();
            //        int l = set.count();
            //        int i;
            //        bool t = true;
            //        for (i = 0; (i < l) && (t); i++)
            //        {
            //            if (!node.getMainSet().getObjects().Contains(set.getObjects()[i]))
            //                t = false;
            //        }
            //        if ((i == l) && (t))
            //        {
            //            flag = true;
            //            tree = node;
            //        }
            //        //else
            //        //{
            //        //    tree = node;
            //        //    break;
            //        //}
            //    }
            //}

            return tr;
        }
Beispiel #4
0
 public void closureOneByOne(FcaMatrix matrix, FcaTree tree)
 {
     FcaObject nextObject = new FcaObject();
     FcaTree node;
     do
     {
         do
         {
             nextObject = matrix.getElemById(tree.getNextId() + 1);
             if (nextObject != null)
             {
                 FcaObjectSet q = new FcaObjectSet();
                 q = tree.getMainSet().clone();
                 q.closure(nextObject, matrix);
                 FcaObjectSet dif =q.difference(tree.getMainSet());
                 if (dif.minObject() == nextObject)
                 {
                     node = new FcaTree();
                     node.setMainSet(q);
                     listOfSets.Add(q);
                     node.setNextId(q.maxObject().getId());
                     node.setParent(tree);
                     tree.addDescendant(node);
                     listOfNodes.Add(node);
                     closureOneByOne(matrix, node);
                     tree.setNextId(nextObject.getId());
                 }
                 else
                 {
                     tree.setNextId(nextObject.getId());
                 }
             }
         } while (nextObject != null);
         if (tree.getParent() != null)
             tree = tree.getParent();
     } while ((tree.getParent() != null) && (nextObject != null));
 }
Beispiel #5
0
        public void buildLattice(FcaTree tree, FcaMatrix matrix)
        {
            FcaObjectSet A = new FcaObjectSet();
            FcaObjectSet G = matrix.UltimateSet();
            List<FcaObjectSet> sup = minimal(A, G, matrix); // множесво всех возможных соседей в решетке
            head = A;
            AllSets = tree.returnListOfSets(tree);
            int i = AllSetsContains(G);
            if (i == -1)
            {
                addAllSets(G);
                i = AllSetsContains(G);
            }
            tail = AllSets[i];

            foreach (FcaObjectSet obj in sup)
            {
                i = AllSetsContains(obj);
                FcaObjectSet existObject = AllSets[i];
                A.addASupr(existObject);
                existObject.addAInf(A);
                addVisited(existObject);
            }

            // найти связь между  1 и 123.
            while (Visited.Count != 0)
            {
                List<FcaObjectSet> list = Visited.ToList<FcaObjectSet>();
                foreach (FcaObjectSet s in list)
                {
                    sup = minimal(s, G, matrix); // множесво всех возможных соседей в решетке
                    Visited.Remove(s);

                    foreach (FcaObjectSet obj in sup)
                    {
                        i = AllSetsContains(obj);
                        if (i == -1)
                        {
                            addAllSets(obj);
                            i = AllSetsContains(obj);
                        }
                        FcaObjectSet existObject = AllSets[i];
                        s.addASupr(existObject);
                        existObject.addAInf(s);
                        addVisited(existObject);
                    }
                }
            }

            foreach (FcaObjectSet set in AllSets)
            {
                FcaObjectSet check = new FcaObjectSet();
                foreach (FcaObjectSet l in set.AInf)
                {
                    foreach (FcaObject o in l.getObjects())
                    {
                        check.addObject(o);
                    }
                }

                if (!set.Equals(check))
                {
                    i = AllSetsContains(set);
                    set.addAInf(tree.findInList(set).getParent().getMainSet());
                }
            }
        }
Beispiel #6
0
 public void addDescendant(FcaTree node)
 {
     this.descendants.Add(node);
 }
Beispiel #7
0
 public void setParent(FcaTree tree)
 {
     this.parent = tree;
 }
Beispiel #8
0
 public List<FcaObjectSet> returnListOfSets(FcaTree tree)
 {
     return this.listOfSets;
 }