Exemple #1
0
        private void PrintRecursively(HybridTrieNode previousNode, HybridTrieNode nextNode, Color color, GraphPrinter graphPrinter)
        {
            if (nextNode != null)
            {
                if (previousNode != null)
                {
                    if (color.Equals(Color.BLUE))
                    {
                        graphPrinter.PrintEdge(previousNode, nextNode, Color.BLUE);
                    }
                    else if (color.Equals(Color.RED))
                    {
                        graphPrinter.PrintEdge(previousNode, nextNode, Color.RED);
                    }
                    else if (color.Equals(Color.GREEN))
                    {
                        graphPrinter.PrintEdge(previousNode, nextNode, Color.GREEN);
                    }

                    if (nextNode.IsFinalNode())
                    {
                        if (color.Equals(Color.BLUE))
                        {
                            graphPrinter.PrintNode(nextNode, Color.BLUE, Color.BLUE, Style.DASHED);
                        }
                        else if (color.Equals(Color.RED))
                        {
                            graphPrinter.PrintNode(nextNode, Color.RED, Color.RED, Style.DASHED);
                        }
                        else if (color.Equals(Color.GREEN))
                        {
                            graphPrinter.PrintNode(nextNode, Color.GREEN, Color.GREEN, Style.DASHED);
                        }
                    }

                    graphPrinter.PrintNodeLabel(nextNode);
                }

                PrintRecursively(nextNode, nextNode.LeftChild, Color.BLUE, graphPrinter);
                PrintRecursively(nextNode, nextNode.MiddleChild, Color.RED, graphPrinter);
                PrintRecursively(nextNode, nextNode.RightChild, Color.GREEN, graphPrinter);
            }
        }
Exemple #2
0
        public void Print(string fileName)
        {
            GraphPrinter graphPrinter = new GraphPrinter(fileName);

            graphPrinter.Begin();

            if (!Root.IsFinalNode())
            {
                graphPrinter.PrintNode(Root);
            }
            else
            {
                graphPrinter.PrintNode(Root, Color.BLACK, Color.BLACK, Style.DASHED);
            }

            graphPrinter.PrintNodeLabel(Root);
            PrintRecursively(null, Root, Color.BLUE, graphPrinter);

            graphPrinter.End();
        }