示例#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);
 }