示例#1
0
        public static void ShowTree(Tree.RootNode root)
        {
            var scriptName = "tree.dot";
            var fileName   = "tree.png";

            CreateTreeScript(root, scriptName);
            RunGraphviz(scriptName, fileName);
            Process.Start(fileName);
        }
示例#2
0
        static void CreateTreeScript(Tree.RootNode root, string fileName)
        {
            var str = new StringBuilder();

            str.AppendFormat("digraph {0} {{ \n", Path.GetFileNameWithoutExtension(fileName));
            foreach (var item in root.ToBreadthFirstList())
            {
                str.AppendFormat("\t{0}_{1}[label=\"{0}\"];\n", item, item.Index);
                PrintTreeNode(item, str);
            }
            str.AppendLine("}");
            File.WriteAllText(fileName, str.ToString());
        }