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; }
public static BitSet BreadthFirstSearch(Tree tree) { Queue<BitSet> queue = new Queue<BitSet>(); queue.Enqueue(tree.Root); BitSet prev = null; while (queue.Count > 0) { BitSet node = queue.Dequeue(); BitSet left = null, right = null; tree.LeftChild.TryGetValue(node, out left); tree.RightChild.TryGetValue(node, out right); if (left == null && right == null) { prev = node; } else { if (left != null) { queue.Enqueue(left); } if (right != null) { queue.Enqueue(right); } } } return prev; }
public Tree Expand(Tree tree) { BitSet parent = tree.Root; while (parent.Count > 1 && tree.RightChild.TryGetValue(parent, out parent)) { } return ReductionRuleHelper.Expand(tree, parent, this.Vertex); }
/*************************/ // Constructor /*************************/ // Basic constructor public GenericSolver(Decomposition decomposition) { // The graph and binary decomposition tree that we are working on _graph = decomposition.Graph; _tree = decomposition.Tree; }
public Tree Expand(Tree tree) { return ReductionRuleHelper.Expand(tree, tree.Root * this.Twin, this.Vertex); }
public Tree Expand(Tree tree) { return ReductionRuleHelper.Expand(tree, this.Connection, this.Vertex); }
// 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; }