public static Tree Expand(Tree tree, BitSet parent, int node) { Tree newTree = new Tree(); Queue<BitSet> queue = new Queue<BitSet>(); queue.Enqueue(tree.Root); while (queue.Count > 0) { BitSet set = queue.Dequeue(); BitSet child; if (tree.LeftChild.TryGetValue(set, out child)) { queue.Enqueue(child); } if (tree.RightChild.TryGetValue(set, out child)) { queue.Enqueue(child); } if (parent.IsSubsetOf(set)) { set += node; } newTree.Insert(set); } newTree.Insert(parent); newTree.Insert(newTree.Root * node); return newTree; }
// Retreives the actual ordering of a certain ordering that will not validate our bound private static Tree RetrieveTree(Datastructures.Graph graph) { Tree tree = new Tree(); Queue<BitSet> queue = new Queue<BitSet>(); queue.Enqueue(graph.Vertices); while (queue.Count != 0) { BitSet a = queue.Dequeue(); tree.Insert(a); if (_optimalChild[a].IsEmpty) continue; queue.Enqueue(_optimalChild[a]); queue.Enqueue(a - _optimalChild[a]); } return tree; }