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); } } } } }
public void AddVertex(BiDirectionalVertex <T> vertex) { if (vertex == null || this.Vertices.Contains(vertex)) { return; } this.Vertices.Add(vertex); }
public void RemoveVertex(BiDirectionalVertex <T> vertex) { if (vertex == null || !this.Vertices.Contains(vertex)) { return; } this.DeLinkMacro(vertex); this.Vertices.Remove(vertex); }
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)))); }
public bool DoesParentExist(BiDirectionalVertex <T> root, BiDirectionalVertex <T> searchVertex) { if (root == null) { return(false); } this.UnVisitAllVertices(); return(this.ParentExist(root, searchVertex)); }
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)))); }
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); }
public void DeLinkMacroParent(BiDirectionalVertex <T> recording) { if (recording == null) { return; } foreach (BiDirectionalVertex <T> parent in recording.Parents) { parent.RemoveChild(recording); } recording.Parents.Clear(); }
public void DeLinkMacroChild(BiDirectionalVertex <T> recording) { if (recording == null) { return; } foreach (BiDirectionalVertex <T> child in recording.Childs) { child.RemoveParent(recording); } recording.Childs.Clear(); }
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); }
public void DeLinkMacro(BiDirectionalVertex <T> recording) { this.DeLinkMacroChild(recording); this.DeLinkMacroParent(recording); }