Esempio n. 1
0
 /// <summary>
 ///  Добавление объекта в множество.
 /// </summary>
 /// <param name="obj">добавляемый объект</param>
 public void addObject(FcaObject obj)
 {
     if (this.objects.Count != 0)
     {
         this.attributes = intersect(obj.getAttributes());
     }
     else {
         this.attributes = obj.getAttributes();
     }
     if (!this.objects.Contains(obj))
                 this.objects.Add(obj);
     this.objects.Sort(compareObjects);
 }
Esempio n. 2
0
        public void addObject(FcaObject obj)
        {
            bool contains = false;
            foreach (FcaObject o in objects)
            {
                if (o.getName().Equals(obj.getName()))
                    contains = true;
            }

            if (!contains)
            {
                obj.setId(objects.Count);
                objects.Add(obj);
            }
        }
Esempio n. 3
0
        public void addAttribute(FcaAttribute attr, FcaObject obj)
        {
            bool contains = false;
            foreach (FcaAttribute at in attributes)
            {
                if (at.getName().Equals(attr.getName()))
                {
                    getObjByName(obj.getName()).addAttr(at);
                    contains = true;
                }
            }

            if (!contains)
            {
                attr.setId(attributes.Count);
                getObjByName(obj.getName()).addAttr(attr);
                attributes.Add(attr);
            }
        }
Esempio n. 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));
 }
Esempio n. 5
0
        private FcaObject getObjByName(String name)
        {
            FcaObject obj = new FcaObject();
            foreach (FcaObject o in objects)
            {
                if (o.getName().Equals(name))
                {
                    obj = o;
                    break;
                }
            }

            return obj;
        }
Esempio n. 6
0
 private int compareObjects(FcaObject x, FcaObject y)
 {
     if (x.getId() > y.getId())
     {
         return 1;
     }
     else if (x.getId() < y.getId())
     {
         return -1;
     }
     else
         return 0;
 }
Esempio n. 7
0
 /// <summary>
 ///     Поиск элемента по имени
 /// </summary>
 /// <param name="elem">Имя элемента</param>
 /// <returns>его порядковый номер</returns>
 public int findElem(FcaObject elem)
 {
     int i = 0;
     int len = this.objects.Count();
     while((i < len) && (this.objects[i].getName() != elem.getName()))
         i++;
     if (i >= len)
         return -1;
     return i;
 }
Esempio n. 8
0
 /// <summary>
 ///  Замыкание множества
 /// </summary>
 /// <param name="elem">добавляемый элемент</param>
 /// <param name="matrix">универсальное множество</param>
 public void closure(FcaObject elem, FcaMatrix matrix)
 {
     addObject(elem);
     int i = 0;
     int len = matrix.count();
     int[] vect = new int[this.attributes.Length];
     while (i < len){
         vect = intersect(matrix.getElemById(i).getAttributes());
         if (attrEquals(vect)&&(i!=elem.getId())) {
             addObject(matrix.getElemById(i));
         }
         i++;
     }
 }