public static ulong InducedSubPatternUpperBound(this ITextTree tree) { if (tree == null) { throw new ArgumentNullException("tree"); } return(InducedSubtreeUpperBound(tree.Root)); }
internal static VisualNode Convert(ITextTree tree) { if (tree == null || tree.Root == null) { return(null); } return(BreadthFirstEnumaration(tree)); }
public static void BuildPreorderIndex(ITextTree textTree) { if (textTree == null) { throw new ArgumentNullException("textTree"); } SetPreorderIndex(textTree.Root, 0); }
public static string ToPreorderString(this ITextTree tree) { if (tree == null) { throw new ArgumentNullException("tree"); } return(tree.Root.ToPreorderString(tree.Separator, tree.BackTrack)); }
public void SubPatternUpperBoundTest_FullBinaryTreeOfDepth6WithNoDuplicationSymbols_210067308558SubPatterns() { const string fullBinaryTreeDepth5 = "Root,A,B,C,D,E,^,F,^,^,G,H,^,I,^,^,^,J,K,L,^,M,^,^,N,O,^,P,^,^,^,^,Q,R,S,T,^,U,^,^,V,W,^,X,^,^,^,Y,Z,a,^,b,^,^,c,d,^,e,^,^,^,^,^,A,B,C,D,E,^,F,^,^,G,H,^,I,^,^,^,J,K,L,^,M,^,^,N,O,^,P,^,^,^,^,Q,R,S,T,^,U,^,^,V,W,^,X,^,^,^,Y,Z,a,^,b,^,^,c,d,^,e,^,^,^,^,^,^"; ITextTree tree = TextTreeBuilder <TextTree, TreeNode> .ConvertToTextTree("001 " + fullBinaryTreeDepth5, Global.Seperator, Global.BackTrack); const ulong expected = 210067308558; var actual = tree.InducedSubPatternUpperBound(); Assert.AreEqual(expected, actual); }
public void SubPatternUpperBoundTest_FullBinaryTreeOfDepth4WithNoDuplicationSymbols_750SubPatterns() { const string fullBinaryTreeDepth4 = "A,B,C,D,^,E,^,^,F,G,^,H,^,^,^,I,J,K,^,L,^,^,M,N,^,O,^,^,^,^"; ITextTree tree = TextTreeBuilder <TextTree, TreeNode> .ConvertToTextTree("001 " + fullBinaryTreeDepth4, Global.Seperator, Global.BackTrack); const ulong expected = 750; var actual = tree.InducedSubPatternUpperBound(); Assert.AreEqual(expected, actual); }
public void SubPatternUpperBoundTest_BinaryTreeWithNoDuplicationSymbols_304SubPatterns() { const string t1 = "A,B,^,C,D,^,E,^,^,F,G,H,^,I,^,^,J,K,^,L,^,^,^,^"; ITextTree tree = TextTreeBuilder <TextTree, TreeNode> .ConvertToTextTree("001 " + t1, Global.Seperator, Global.BackTrack); const ulong expected = 304; var actual = tree.InducedSubPatternUpperBound(); Assert.AreEqual(expected, actual); }
public static void Canonicalize(ITextTree tree) { if (tree == null) { throw new ArgumentNullException("tree"); } if (tree.Root != null) { Sort(tree.Root); } }
public void SetTree(ITextTree tree) { if (tree != null) { txtTextTree.Text = string.Format("TreeID:{0}\t{1}", tree.TreeId, tree.ToPreorderString()); } node = VisualNode.Convert(tree); indent.Clear(); BuildIndent(node); pnlCanvas.Invalidate(); }
static VisualNode BreadthFirstEnumaration(ITextTree tree) { var nodeQueue = new Queue <VisualNode>(); var root = new VisualNode { X = 0, Y = 0, TreeNode = tree.Root }; nodeQueue.Enqueue(root); var curDepth = 0; var x = 0; while (nodeQueue.Count > 0) { var node = nodeQueue.Dequeue(); if (curDepth != node.Y) { x = node.X; curDepth = node.Y; } if (node.TreeNode.Children == null) { continue; } node.Children = new List <VisualNode>(); foreach (var tn in node.TreeNode.Children) { var vn = new VisualNode { X = x++, Y = node.Y + 1, TreeNode = tn }; node.Children.Add(vn); nodeQueue.Enqueue(vn); } } return(root); }