Beispiel #1
0
        private OntologyClass Find(string name, bool up)
        {
            OntologyClass           klass  = null;
            HashSet <OntologyClass> viewed = new HashSet <OntologyClass>();
            Stack <OntologyClass>   s      = new Stack <OntologyClass>();

            s.Push(this);
            while (s.Any())
            {
                OntologyClass currentKlass = s.Pop();
                if (currentKlass.Name.Equals(name))
                {
                    klass = currentKlass;
                    break;
                }
                var collection = up ? currentKlass.Parents : currentKlass.Children;
                if (collection.Count > 0)
                {
                    var currentKlassViewed = true;
                    foreach (OntologyClass el in collection)
                    {
                        if (!viewed.Contains(el))
                        {
                            s.Push(el);
                            currentKlassViewed = false;
                        }
                    }
                    if (currentKlassViewed)
                    {
                        viewed.Add(currentKlass);
                    }
                }
            }
            return(klass);
        }
Beispiel #2
0
 public void AddParent(OntologyClass p)
 {
     _parents.Add(p);
 }
Beispiel #3
0
 public void AddChild(OntologyClass c)
 {
     _children.Add(c);
 }