private void Replace(Sink sink, Node node) { if (sink.ParentList.Count == 0) _head = node; else node.Replace(sink); }
protected Node(Node left, Node right) { ParentList = new List<Node>(); LeftChild = left; RightChild = right; if (left != null) left.ParentList.Add(this); if (right != null) right.ParentList.Add(this); }
// Replace a node in the graph with this node // Make sure parent pointers are updated public void Replace(Node node) { foreach (Node parent in node.ParentList) { // Select the correct node to replace (left or right child) if (parent.LeftChild == node) parent.LeftChild = this; else parent.RightChild = this; } ParentList.AddRange(node.ParentList); }
public QueryGraph(Node head) { _head = head; }