예제 #1
0
        public List <BiDirectionalVertex <T> > GetAllChilds(
            BiDirectionalVertex <T> vertex)
        {
            List <BiDirectionalVertex <T> > dependents = new List <BiDirectionalVertex <T> >();

            if (vertex != null)
            {
                GetChilds(vertex);
            }
            return(dependents);

            void GetChilds(BiDirectionalVertex <T> node)
            {
                foreach (BiDirectionalVertex <T> child in node.Childs)
                {
                    if (!dependents.Contains(child))
                    {
                        dependents.Add(child);
                        if (child.Childs.Count > 0)
                        {
                            GetChilds(child);
                        }
                    }
                }
            }
        }
예제 #2
0
 public void AddVertex(BiDirectionalVertex <T> vertex)
 {
     if (vertex == null || this.Vertices.Contains(vertex))
     {
         return;
     }
     this.Vertices.Add(vertex);
 }
예제 #3
0
 public void RemoveVertex(BiDirectionalVertex <T> vertex)
 {
     if (vertex == null || !this.Vertices.Contains(vertex))
     {
         return;
     }
     this.DeLinkMacro(vertex);
     this.Vertices.Remove(vertex);
 }
예제 #4
0
 private bool ParentExist(BiDirectionalVertex <T> root, BiDirectionalVertex <T> searchVertex)
 {
     if (root.IsVisited)
     {
         return(false);
     }
     root.IsVisited = true;
     return(root.Equals((object)searchVertex) || root.Parents.Any <BiDirectionalVertex <T> >((Func <BiDirectionalVertex <T>, bool>)(parent => this.ParentExist(parent, searchVertex))));
 }
예제 #5
0
 public bool DoesParentExist(BiDirectionalVertex <T> root, BiDirectionalVertex <T> searchVertex)
 {
     if (root == null)
     {
         return(false);
     }
     this.UnVisitAllVertices();
     return(this.ParentExist(root, searchVertex));
 }
예제 #6
0
 private bool ChildExist(BiDirectionalVertex <T> root, BiDirectionalVertex <T> searchVertex)
 {
     if (root.IsVisited)
     {
         return(false);
     }
     root.IsVisited = true;
     return(root.Equals((object)searchVertex) || root.Childs.Any <BiDirectionalVertex <T> >((Func <BiDirectionalVertex <T>, bool>)(child => this.ChildExist(child, searchVertex))));
 }
예제 #7
0
 public void AddParentChild(BiDirectionalVertex <T> parent, BiDirectionalVertex <T> child)
 {
     if (parent == null || child == null)
     {
         return;
     }
     this.AddVertex(parent);
     this.AddVertex(child);
     this.AddParentChildRelation(parent, child);
 }
예제 #8
0
 public void DeLinkMacroParent(BiDirectionalVertex <T> recording)
 {
     if (recording == null)
     {
         return;
     }
     foreach (BiDirectionalVertex <T> parent in recording.Parents)
     {
         parent.RemoveChild(recording);
     }
     recording.Parents.Clear();
 }
예제 #9
0
 public void DeLinkMacroChild(BiDirectionalVertex <T> recording)
 {
     if (recording == null)
     {
         return;
     }
     foreach (BiDirectionalVertex <T> child in recording.Childs)
     {
         child.RemoveParent(recording);
     }
     recording.Childs.Clear();
 }
예제 #10
0
 private void AddParentChildRelation(BiDirectionalVertex <T> parent, BiDirectionalVertex <T> child)
 {
     if (parent == null || child == null)
     {
         return;
     }
     if (!child.Parents.Contains(parent))
     {
         child.AddParent(parent);
     }
     if (parent.Childs.Contains(child))
     {
         return;
     }
     parent.AddChild(child);
 }
 public void RemoveParent(BiDirectionalVertex <T> newParent)
 {
     this.Parents.Remove(newParent);
 }
 public void AddParent(BiDirectionalVertex <T> newParent)
 {
     this.Parents.Add(newParent);
 }
 public void RemoveChild(BiDirectionalVertex <T> newChild)
 {
     this.Childs.Remove(newChild);
 }
 public void AddChild(BiDirectionalVertex <T> newChild)
 {
     this.Childs.Add(newChild);
 }
예제 #15
0
 public void DeLinkMacro(BiDirectionalVertex <T> recording)
 {
     this.DeLinkMacroChild(recording);
     this.DeLinkMacroParent(recording);
 }