Esempio n. 1
0
        private void inputButton_Click(object sender, EventArgs e)
        {
            var input = inputTextBox.Text;

            suffixTree = new SuffixTree(input);
            suffixTree.Build();

            DrawTree(suffixTree);

            //DrawTree(suffixTree);
        }
Esempio n. 2
0
        private void DrawTree(SuffixTree suffixTree)
        {
            suffixTree.removeMarks();
            dX = sheet.Width / suffixTree.nodeNumber;

            drawTree = new DrawTree(sheet.Width, sheet.Height, suffixTree.input);
            var x = drawTree.R + 10;
            var y = drawTree.R;

            //drawTree.clearSheet();
            sheet.Image = drawTree.GetBitmap();
            drawTree.clearSheet();

            suffixTree.theStack.Push(suffixTree.root);
            suffixTree.root.wasVisited = true;

            suffixTree.root.center.X = sheet.Width / 2;
            suffixTree.root.center.Y = y;

            drawTree.DrawNode(suffixTree.root.center);

            SuffixNode currentNode = null;
            SuffixNode parentNode  = null;

            while (suffixTree.theStack.Count != 0)
            {
                parentNode  = suffixTree.theStack.Peek();
                currentNode = suffixTree.getUnvisitedChild(suffixTree.theStack.Peek());
                if (currentNode == null)
                {
                    suffixTree.theStack.Pop();
                    y -= dY;
                }
                else
                {
                    y += dY;
                    currentNode.wasVisited = true;
                    suffixTree.theStack.Push(currentNode);
                    sheet.Image = drawTree.GetBitmap();

                    currentNode.center.X = x;
                    currentNode.center.Y = y;

                    drawTree.DrawEdge(parentNode, currentNode);
                    x += dX;
                }
            }

            for (var i = 0; i < suffixTree.selectedLeafs.Count; i++)
            {
                drawTree.DrawSelectedLeaf(suffixTree.selectedLeafs[i]);
            }
        }