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); }
public void AddParent(OntologyClass p) { _parents.Add(p); }
public void AddChild(OntologyClass c) { _children.Add(c); }