Пример #1
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName + ".dot";

            File.WriteAllText(output, dot);
            return(output);
        }
Пример #2
0
        /// <summary>
        ///     Saves the given <see cref="ITreeNode" /> to an image file.
        /// </summary>
        /// <param name="rootNode">The root node of the tree to be saved.</param>
        /// <param name="basePath">The path in which to save the given tree</param>
        /// <param name="fileName">The name of the image file to be saved (without extension)</param>
        /// <param name="formatVertex">The delegate used to format the vertexes.</param>
        /// <param name="formatEdge">The delegate used to format the edges.</param>
        /// <param name="imageType">The type of image file in which to save the tree.</param>
        /// <param name="timeout">The maximum time to wait for Graphviz to create the image file.</param>
        /// <returns>The path to file where the tree image file was saved.</returns>
        public static string ToGraphvizFile(
            this ITreeNode rootNode, string basePath, string fileName,
            FormatVertexEventHandler <Vertex> formatVertex,
            FormatEdgeAction <Vertex, Edge> formatEdge,
            GraphvizImageType imageType = GRAPHVIZ_IMAGE_TYPE, int timeout = GRAPHVIZ_TIMEOUT_MS)
        {
            var graph = new AdjacencyGraph <Vertex, Edge>();

            GraphAdd(rootNode, graph, new Dictionary <ITreeNode, Vertex>());

            var filePath = Path.Combine(basePath, $"{fileName}.dot");

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            var viz = new GraphvizAlgorithm <Vertex, Edge>(graph)
            {
                ImageType = imageType
            };

            if (formatVertex != null)
            {
                viz.FormatVertex += formatVertex;
            }
            if (formatEdge != null)
            {
                viz.FormatEdge += formatEdge;
            }
            return(viz.Generate(new FileDotEngine(timeout), filePath));
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataSetGraphvizAlgorithm"/> class.
 /// </summary>
 /// <param name="visitedGraph">Graph to convert to DOT.</param>
 /// <param name="imageType">Target output image type.</param>
 public DataSetGraphvizAlgorithm(
     [NotNull] DataSetGraph visitedGraph,
     GraphvizImageType imageType)
     : base(visitedGraph, imageType)
 {
     InitializeFormat();
 }
Пример #4
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            using (var process = new Process())
            {
                var graphFileContext = string.Format("{0}.{1}", outputFileName, "txt");

                using (var graphFile = new StreamWriter(graphFileContext))
                {
                    graphFile.Write(dot);
                    graphFile.Flush();
                }

                string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
                // ReSharper disable AssignNullToNotNullAttribute
                process.StartInfo.FileName         = Path.Combine(currentDirectory, DotExeFileName);
                process.StartInfo.WorkingDirectory = currentDirectory;

                // ReSharper restore AssignNullToNotNullAttribute

                process.StartInfo.Arguments = string.Format(@"-T{0} -o""{1}"" ""{2}""", imageType.ToString().ToLower(), outputFileName, graphFileContext);

                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError  = true;

                process.StartInfo.UseShellExecute = false;
                process.Start();

                return(process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd());
            }
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="imageType"></param>
        /// <param name="dot">The dot-representation of the graph in question</param>
        /// <param name="outputFileName">The output file</param>
        /// <returns></returns>
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            if (!outputFileName.EndsWith(".dot", StringComparison.CurrentCultureIgnoreCase))
            {
                outputFileName = outputFileName + ".dot";
            }
            using (var writer = File.CreateText(outputFileName))
            {
                writer.Write(dot);
            }

            #region Run dot.exe program
            var args = string.Format(@"{0} -Tpng -o {0}.png", outputFileName);
            try
            {
                Process.Start(_dotProgramLocation, args);
            }
            catch (FileNotFoundException ex)
            {
                throw new FileNotFoundException($"Could not find dot.exe program in path: {_dotProgramLocation}", ex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            #endregion
            return(outputFileName);
        }
Пример #6
0
 /// <summary>
 ///     Saves the given <see cref="ITreeNode" /> to an image file.
 /// </summary>
 /// <param name="rootNode">The root node of the tree to be saved.</param>
 /// <param name="basePath">The path in which to save the given tree</param>
 /// <param name="fileName">The name of the image file to be saved (without extension)</param>
 /// <param name="imageType">The type of image file in which to save the tree.</param>
 /// <param name="timeout">The maximum time to wait for Graphviz to create the image file.</param>
 /// <returns>The path to file where the tree image file was saved.</returns>
 public static string ToGraphvizFile(
     this ITreeNode rootNode, string basePath, string fileName,
     GraphvizImageType imageType = GRAPHVIZ_IMAGE_TYPE, int timeout = GRAPHVIZ_TIMEOUT_MS)
 {
     return(rootNode.ToGraphvizFile(
                basePath, fileName, OnFormatElementVertex, OnFormatElementEdge, imageType, timeout));
 }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="g">graph to plot</param>
        /// <param name="prefix">prefix of generated images</param>
        /// <param name="outputPath">output path for image files</param>
        /// <param name="imageType">ouput type</param>
        public AlgorithmTracerVisitor(
            IVertexAndEdgeListGraph g,
            String prefix,
            String outputPath,
            GraphvizImageType imageType
            )
        {
            if (prefix == null)
            {
                throw new ArgumentNullException("prefix");
            }
            if (outputPath == null)
            {
                throw new ArgumentNullException("tempPath");
            }

            m_VertexLabels = null;
            m_EdgeLabels   = null;

            m_Colors     = null;
            m_EdgeColors = new EdgeColorDictionary();

            m_FileName    = prefix;
            m_CurrentFile = 0;

            m_Algo = new GraphvizAlgorithm(g, outputPath, imageType);
            m_Algo.RegisterVisitor(this);
        }
Пример #8
0
            public string Run(GraphvizImageType imageType, string dot, string fileName)
            {
                string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;

                string dotFileName = $"{fileName}.dot";
                string dotPath     = Path.Combine(currentDirectory, ImagesPath, dotFileName);

                string imageFileName = $"{fileName}{index}.png";
                string imagePath     = Path.Combine(currentDirectory, ImagesPath, imageFileName);

                File.Delete(imagePath);

                index++;

                imageFileName = $"{fileName}{index}.png";
                string imagesDirectoryPath = Path.Combine(currentDirectory, ImagesPath);

                imagePath = Path.Combine(imagesDirectoryPath, imageFileName);

                File.WriteAllText(dotPath, dot);

                ProcessStartInfo startInfo =
                    new ProcessStartInfo
                {
                    FileName        = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Settings.Default.GraphvizDotPath),
                    Arguments       = $@"dot -T png {dotPath} -o {imagePath}",
                    UseShellExecute = false,
                    CreateNoWindow  = true,
                };

                Process.Start(startInfo)?.WaitForExit(1000);
                return(imagePath);
            }
Пример #9
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            using (var process = new Process())
            {
                var graphFileContext = string.Format("{0}.{1}", outputFileName, "txt");

                using (var graphFile = new StreamWriter(graphFileContext))
                {
                    graphFile.Write(dot);
                    graphFile.Flush();
                }

                string currentDirectory = AppDomain.CurrentDomain.BaseDirectory;
                // ReSharper disable AssignNullToNotNullAttribute
                process.StartInfo.FileName = Path.Combine(currentDirectory, DotExeFileName);
                process.StartInfo.WorkingDirectory = currentDirectory;

                // ReSharper restore AssignNullToNotNullAttribute

                process.StartInfo.Arguments = string.Format(@"-T{0} -o""{1}"" ""{2}""", imageType.ToString().ToLower(), outputFileName, graphFileContext);

                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;

                process.StartInfo.UseShellExecute = false;
                process.Start();

                return process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
            }
        }
Пример #10
0
        /// <summary>
        /// Builds a new Graphviz writer of the graph g using the Stream s.
        /// </summary>
        /// <param name="g">Graph to visit.</param>
        /// <param name="path">Path where files are to be created</param>
        /// <param name="imageType">output image type</param>
        /// <exception cref="ArgumentNullException">g is a null reference</exception>
        /// <exception cref="ArgumentNullException">path is a null reference</exception>
        public GraphvizAlgorithm(
            IVertexAndEdgeListGraph g,
            String path,
            GraphvizImageType imageType
            )
        {
            if (g == null)
            {
                throw new ArgumentNullException("g");
            }
            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            m_VisitedGraph = g;
            m_StringWriter = null;
            m_Dot          = new Dot(path);
            m_ImageType    = imageType;

            clusterCount  = 0;
            m_GraphFormat = new GraphvizGraph();

            m_CommonVertexFormat = new GraphvizVertex();
            m_CommonEdgeFormat   = new GraphvizEdge();

            m_VertexFormat = new GraphvizVertex();
            m_EdgeFormat   = new GraphvizEdge();
        }
Пример #11
0
 /// <summary>
 /// Runs graph generation code.
 /// </summary>
 /// <param name="imageType"></param>
 /// <param name="dot"></param>
 /// <param name="outputFileName"></param>
 /// <returns></returns>
 public string Run(GraphvizImageType imageType, string dot, string outputFileName)
 {
     string output = outputFileName;
     File.WriteAllText(output, dot);
     var args = string.Format($"{output} -Tjpg -O");
     System.Diagnostics.Process.Start("TAIO_Execs\\dot.exe", args);
     return output;
 }
Пример #12
0
 /// <summary>
 /// Writes the dot code to the dotFileName and then executes dot on it.
 /// </summary>
 /// <param name="dotCode"></param>
 /// <param name="imageType"></param>
 /// <returns>output file name</returns>
 public String Render(
     String dotCode,
     GraphvizImageType imageType
     )
 {
     ImageType = imageType;
     return(Render(dotCode));
 }
Пример #13
0
        string IDotEngine.Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            Contract.Requires(!String.IsNullOrEmpty(dot));
            Contract.Requires(!String.IsNullOrEmpty(outputFileName));
            Contract.Ensures(!String.IsNullOrEmpty(Contract.Result<string>()));

            return null;
        }
Пример #14
0
 /// <summary>
 ///     Saves the given <see cref="IInformationTree{TProgram}" /> to an image file.
 /// </summary>
 /// <typeparam name="TProgram">The type of program.</typeparam>
 /// <param name="tree">The information tree to be saved.</param>
 /// <param name="basePath">The path in which to save the given information tree</param>
 /// <param name="fileName">The name of the image file to be saved (without extension)</param>
 /// <param name="imageType">The type of image file in which to save the tree.</param>
 /// <param name="timeout">The maximum time to wait for Graphviz to create the image file.</param>
 /// <returns>The path to file where the tree image file was saved.</returns>
 public static string ToGraphvizFile <TProgram>(
     this IInformationTree <TProgram> tree, string basePath, string fileName,
     GraphvizImageType imageType = GRAPHVIZ_IMAGE_TYPE, int timeout = GRAPHVIZ_TIMEOUT_MS)
     where TProgram : ITreeProgram
 {
     return(tree.RootNode.ToGraphvizFile(
                basePath, fileName, OnFormatInfoVertex, OnFormatInfoEdge, imageType, timeout));
 }
Пример #15
0
        string IDotEngine.Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            Contract.Requires(!String.IsNullOrEmpty(dot));
            Contract.Requires(!String.IsNullOrEmpty(outputFileName));
            Contract.Ensures(!String.IsNullOrEmpty(Contract.Result <string>()));

            return(null);
        }
 public string Run(GraphvizImageType imageType, string dot, string outputFileName)
 {
     using (StreamWriter writer = new StreamWriter(outputFileName))
     {
         writer.Write(dot);
     }
     return(System.IO.Path.GetFileName(outputFileName));
 }
Пример #17
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName;
            if (!output.EndsWith(".dot", StringComparison.InvariantCultureIgnoreCase))
                output = output + ".dot";

            File.WriteAllText(output, dot);
            return output;
        }
Пример #18
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            // Make sure directory exists
            var outputDirectory = Path.GetDirectoryName(outputFileName);

            Directory.CreateDirectory(outputDirectory);

            // API doesn't seem to support HTML based nodes, so we need to drop the quotes on the label output.
            string mungedDot = Regex.Replace(
                dot,
                @"label=""(<.*?>)""",
                "label=$1", RegexOptions.Singleline);

            // API doesn't support "none" border type, but we don't want anything around our HTML
            mungedDot = mungedDot.Replace("plaintext", "none, margin=0");

            // Write out the "munged" dot file
            File.WriteAllText(outputFileName, mungedDot);

            // Now unflatten the dot file (if requested)
            if (_unflattenToDepth > 0)
            {
                var unflattenArgs = string.Format(@"-o ""{0}.unflattened"" -l{1} ""{0}""", outputFileName, _unflattenToDepth);

                Process.Start(
                    new ProcessStartInfo(@"C:\Program Files (x86)\Graphviz2.38\bin\unflatten.exe", unflattenArgs)
                {
                    UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true
                });

                outputFileName = outputFileName + ".unflattened";
            }

            string[] outputTypes =
            {
                "png", "svg"
            };

            foreach (string outputType in outputTypes)
            {
                string outputImageFileName = Path.ChangeExtension(outputFileName, outputType);

                var args = string.Format(
                    @"""{0}"" -T{2} -o""{1}""",
                    outputFileName,
                    outputImageFileName,
                    outputType);

                Process.Start(
                    new ProcessStartInfo(@"C:\Program Files (x86)\Graphviz2.38\bin\dot.exe", args)
                {
                    UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, WorkingDirectory = _assetsFolder
                });
            }

            return(outputFileName);
        }
 public DataSetGraphvizAlgorithm(
     DataSetGraph visitedGraph,
     string path,
     GraphvizImageType imageType
     )
     : base(visitedGraph, path, imageType)
 {
     this.InitializeFormat();
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphvizAlgorithm{TVertex,TEdge}"/> class.
 /// </summary>
 /// <param name="graph">Graph to convert to DOT.</param>
 /// <param name="imageType">Target output image type.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
 public GraphvizAlgorithm(
     [NotNull] IEdgeListGraph <TVertex, TEdge> graph,
     GraphvizImageType imageType)
 {
     ClusterCount       = 0;
     _visitedGraph      = graph ?? throw new ArgumentNullException(nameof(graph));
     ImageType          = imageType;
     GraphFormat        = new GraphvizGraph();
     CommonVertexFormat = new GraphvizVertex();
     CommonEdgeFormat   = new GraphvizEdge();
 }
Пример #21
0
    public string Run(GraphvizImageType imageType, string dot, string outputFileName)
    {
        string output = outputFileName;

        File.WriteAllText(output, dot);
        // assumes dot.exe is in the path EnvVar:
        var args = $@"{output} -Tjpg -O";

        System.Diagnostics.Process.Start("dot", args);
        return(output);
    }
Пример #22
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                string output = outputFileName;

                File.WriteAllText(output, dot);

                var args = string.Format(@"{0} {1}", output, Settings.GraphvizArguments);

                Process.Start(Settings.GraphvizPath, args);
                return(output);
            }
Пример #23
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName;
            if(!output.EndsWith(".dot"))
            {
                output += ".dot";
            }

            File.WriteAllText(output, dot);
            return output;
        }
    public string Run(GraphvizImageType imageType, string dot, string outputFileName)
    {
        string output = outputFileName;

        File.WriteAllText(output, dot);
        // assumes dot.exe is on the path:
        var args = string.Format(@"{0} -Tjpg c:\temp\products.dot -O", output);

        System.Diagnostics.Process.Start("dot.exe", args);
        return(output);
    }
Пример #25
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                // Maybe read from stdin?
                File.WriteAllText(outputFileName, dot);

                var imagePath = Path.ChangeExtension(outputFileName, "svg");
                var args      = $"{outputFileName} -Tsvg -o\"{imagePath}\"";

                System.Diagnostics.Process.Start("dot", args).WaitForExit();

                return(imagePath);
            }
Пример #26
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName;

            if (!output.EndsWith(".dot"))
            {
                output += ".dot";
            }

            File.WriteAllText(output, dot);
            return(output);
        }
Пример #27
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName;

            if (!output.EndsWith(".dot", StringComparison.InvariantCultureIgnoreCase))
            {
                output = output + ".dot";
            }

            File.WriteAllText(output, dot);
            return(output);
        }
Пример #28
0
            /// <summary>
            /// Run: Run the FileDotEngine
            /// Parameter fileInfo contains the output filepath and optionally the image layout.
            /// The filepath and image layout are separated by a space ' '.
            /// For example: "{imageFilepath} {layout}" where
            /// outputFilepath = "D:\\Samples\\QuikGraph\\QuikSample\\Graphs\\filename"
            /// layout = ImageLayout.circo
            /// </summary>
            /// <param name="imageType"></param>
            /// <param name="dotContents"></param>
            /// <param name="fileInfo"></param>
            /// <returns></returns>
            public string Run(GraphvizImageType imageType, string dotContents, string fileInfo)
            {
                var         filepath = fileInfo.Split(' ');
                string      filename = filepath[0];
                ImageLayout layout   = ImageLayout.none;

                if (filepath.Length > 1)
                {
                    Enum.TryParse(filepath[1], true, out layout);
                }

                return(Run(imageType, dotContents, filename, layout));
            }
Пример #29
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                string output = outputFileName;

                File.WriteAllText(output, dot);

                // assumes dot.exe is on the path:
                var dotargs = string.Format(@"{0} -Tjpg -O", output);

                System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Graphviz2.38\bin\dot.exe", dotargs);

                return(output);
            }
Пример #30
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                string output = outputFileName;

                File.WriteAllText(output, dot);


                // assumes dot.exe is on the path:
                var args = string.Format(@"{0} -Tjpg -O", output);

                System.Diagnostics.Process.Start(@"C:\Users\dimar\source\repos\Proiect_PAW\packages\Graphviz.2.38.0.2\dot.exe", args);
                return(output);
            }
Пример #31
0
        public string ExportImageFile(UndirectedGraph <int, Edge <int> > graph, GraphvizImageType imageType, string filepath, ImageLayout layout)
        {
            var graphviz = new GraphvizAlgorithm <int, Edge <int> >(graph)
            {
                ImageType = imageType
            };

            graphviz.FormatVertex += VertexFormatter;

            string fileInfo = $"{filepath} {layout}";

            graphviz.Generate(new FileDotEngine(), fileInfo);
            return(filepath);
        }
        public string Run(GraphvizImageType imageType, 
                          string dot, 
                          string outputFileName)
        {
            string output = outputFileName; // +".dot";

            using (var sw = new StreamWriter(output))
            {
                sw.Write(dot);
                sw.Close();
            }

            return output;
        }
Пример #33
0
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName;

            dot = dot.Replace('>', '-');
            File.WriteAllText(output, dot);
            ProcessStartInfo startInfo = new ProcessStartInfo("dot.exe");

            startInfo.Arguments = string.Format(@"-Tpng {0} -o {0}.png", output);
            var process = Process.Start(startInfo);

            process.WaitForExit();
            return(output);
        }
Пример #34
0
        public string Run(GraphvizImageType imageType,
                          string dot,
                          string outputFileName)
        {
            string output = outputFileName; // +".dot";

            using (var sw = new StreamWriter(output))
            {
                sw.Write(dot);
                sw.Close();
            }

            return(output);
        }
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            // using (FileStream stream = new FileStream(outputFileName, FileMode.Create, FileAccess.Write, FileShare.None))
            // {
            //     StreamWriter writer = new StreamWriter(stream);
            //     writer.WriteLine(dot);
            // }

            string outputDir = "output";

            File.WriteAllText(Path.Combine(outputDir, outputFileName + ".txt"), dot);

            return outputFileName;
        }
Пример #36
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                // writes .dot file with the tree and converts it to an image
                File.WriteAllText(outputFileName, dot);
                var args        = $"\"{outputFileName}\" -T{imageType.GetOutputFormatStr()} -O";
                var processInfo = new ProcessStartInfo("dot", args)
                {
                    UseShellExecute        = false,
                    RedirectStandardOutput = true
                };
                var process = Process.Start(processInfo);

                process?.WaitForExit(this._timeout);
                return(outputFileName);
            }
Пример #37
0
        public GraphvizAlgorithm(
            IEdgeListGraph <TVertex, TEdge> g,
            String path,
            GraphvizImageType imageType
            )
        {
            Contract.Requires(g != null);
            Contract.Requires(!String.IsNullOrEmpty(path));

            this.visitedGraph       = g;
            this.imageType          = imageType;
            this.graphFormat        = new GraphvizGraph();
            this.commonVertexFormat = new GraphvizVertex();
            this.commonEdgeFormat   = new GraphvizEdge();
        }
        public string Run(GraphvizImageType imageType, string dot, string outputFileName)
        {
            string output = outputFileName + ".dot";

            //Find and replace "->" in string with "--"
            //(assuming input is made from an undirected graphs)

            // IMPORTANT NB:

            // Graphviz expects edges to be written as:

            // '0 -- 1' for undirected graphs and will syntax error on the '->' produced by the library

            string modifiedOutputStr = dot.Replace("->", "--");

            File.WriteAllText(output, modifiedOutputStr);
            return output;
        }
Пример #39
0
        private string CreateImageFile(object o, GraphvizImageType imageType, string imageFileName)
        {
            var graph = FactoryProvider.CreateStringGraph();
            FactoryProvider.CreateGraphCreator().Create(o, graph);
            var graphviz = new GraphvizAlgorithm<string, TaggedEdge<string, string>>(graph.ToQuickGraph())
                {
                    ImageType = imageType
                };

            graphviz.FormatVertex += FormatVertexHandler;

            // ReSharper disable AssignNullToNotNullAttribute
            string outputfile = Path.Combine(Path.GetDirectoryName(Environment.CurrentDirectory), imageFileName);
            // ReSharper restore AssignNullToNotNullAttribute

            graphviz.Generate(new FileDotEngine(), outputfile);
            return outputfile;
        }
Пример #40
0
        public void Render(string outputPath, GraphvizImageType imageType)
        {
            if (DebugSettings.GraphMethod != null && MethodCompileInfo.Method.ToString() != DebugSettings.GraphMethod)
            {
                return;
            }
            GraphvizAlgorithm algorithm = new GraphvizAlgorithm(Graph);

            algorithm.GraphFormat.Label = MethodCompileInfo.Method.ToString();
            algorithm.CommonVertexFormat.Shape = GraphvizVertexShape.Rectangle;
            algorithm.CommonVertexFormat.Style = GraphvizVertexStyle.Filled;
            algorithm.CommonVertexFormat.Font = new System.Drawing.Font("Tahoma", 10);
            algorithm.CommonEdgeFormat.Font = new System.Drawing.Font("Tahoma", 10);

            algorithm.ImageType = imageType;

            algorithm.FormatEdge += new FormatEdgeEventHandler(algorithm_FormatEdge);
            algorithm.FormatVertex += new FormatVertexEventHandler(algorithm_FormatVertex);

            algorithm.Write(outputPath);
        }
Пример #41
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        /// <param name="prefix"></param>
        /// <param name="path"></param>
        /// <param name="imageType"></param>
        public AlgorithmTracerVisitor(
            IVertexAndEdgeListGraph g,
            String prefix,
            String path,
            GraphvizImageType imageType
            )
        {
            m_Vertex = new GraphvizVertex();
            m_Vertex.Shape = GraphvizVertexShape.Circle;
            m_Vertex.Style = GraphvizVertexStyle.Filled;
            m_VertexLabels =null;

            m_Edge = new GraphvizEdge();
            m_EdgeLabels = null;

            m_Colors = null;
            m_EdgeColors = new EdgeColorDictionary();

            m_Algo = new GraphvizAlgorithm(g,prefix,path,imageType);
            m_Algo.RegisterVisitor(this);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">graph to plot</param>
        /// <param name="prefix">prefix of generated images</param>
        /// <param name="outputPath">output path for image files</param>
        /// <param name="imageType">ouput type</param>
        public AlgorithmTracerVisitor(
            IVertexAndEdgeListGraph g,
            String prefix,
            String outputPath,
            GraphvizImageType imageType
            )
        {
            if (prefix==null)
                throw new ArgumentNullException("prefix");
            if (outputPath==null)
                throw new ArgumentNullException("tempPath");

            m_VertexLabels =null;
            m_EdgeLabels = null;

            m_Colors = null;
            m_EdgeColors = new EdgeColorDictionary();

            m_FileName = prefix;
            m_CurrentFile = 0;

            m_Algo = new GraphvizAlgorithm(g,outputPath,imageType);
            m_Algo.RegisterVisitor(this);
        }
Пример #43
0
 public string Run(GraphvizImageType imageType, string dot, string outputFileName)
 {
     string output = outputFileName + ".dot";
     File.WriteAllText(output, dot);
     return output;
 }
Пример #44
0
        private string RenderCondGraph(CondensedTypeGraph g, GraphvizImageType imageType, string outputFile)
        {
            string output;
            GraphvizAlgorithm renderer;

            renderer = new GraphvizAlgorithm( g);
            renderer.ImageType = imageType;
            renderer.FormatCluster += new FormatClusterEventHandler(renderer_FormatCluster);
            renderer.GraphFormat.IsCentered = true;
            renderer.GraphFormat.RankDirection = GraphvizRankDirection.TB;
            renderer.FormatVertex += new FormatVertexEventHandler(FormatCCCVertex);
            renderer.FormatEdge += new FormatEdgeEventHandler(graphvis_edgeFormatterNN);
            output = renderer.Write(outputFile);
            return output;
        }
Пример #45
0
        private string RenderAnalysisGraph(TypeDependencyGraph tdg, GraphvizImageType imageType,string fileName)
        {
            string output;
            GraphvizAlgorithm renderer;
            renderer = new GraphvizAlgorithm(tdg);
            renderer.ImageType = imageType;
            renderer.GraphFormat.RankDirection = GraphvizRankDirection.LR;
            Color[] colors = {
                Color.Beige,
                Color.Cornsilk,
                Color.DimGray,
                Color.Khaki,
                Color.PeachPuff,
                Color.Wheat,
                Color.Olive,
                Color.Moccasin,
                Color.LightCoral,
                Color.LightGoldenrodYellow,
                Color.LightGray,
                Color.LightGreen,
                Color.LightPink,
                Color.LightSalmon,
                Color.LightSeaGreen,
                Color.LightSkyBlue,
                Color.LightSlateGray,
                Color.LightSteelBlue,
                Color.LightYellow,
                Color.Lime,
                Color.MediumAquamarine,
                Color.MediumBlue,
                Color.MediumOrchid,
                Color.MediumPurple,
                Color.MediumSeaGreen,
                Color.MediumSlateBlue,
                Color.MediumSpringGreen,
                Color.MediumTurquoise,
                Color.MediumVioletRed,
                Color.MintCream,

            };
            int nextColorInd = 0;
            Dictionary<int,Color> colormap = new Dictionary<int,Color>();
            FormatVertexEventHandler fvertex = delegate(Object s, FormatVertexEventArgs args)
            {
                TypeVertex v = (TypeVertex)args.Vertex;
                args.VertexFormatter.Label = v.Name;
                args.VertexFormatter.Font = new Font(FontFamily.GenericSerif, 8);
                if (v.SCCNum>=0)
                {
                    Color c;
                    if (!colormap.TryGetValue(v.SCCNum,out c))
                    {
                        if (nextColorInd > colors.GetUpperBound(0)) nextColorInd = 0;
                        c = colors[nextColorInd++];
                        colormap[v.SCCNum] = c;
                    }
                    args.VertexFormatter.FillColor = c;
                    args.VertexFormatter.Style = GraphvizVertexStyle.Filled;
                }
            };

            FormatEdgeEventHandler Fedge = delegate(Object s, FormatEdgeEventArgs args)
                {
                    args.EdgeFormatter.Head = new GraphvizEdgeExtremity(true);
                    args.EdgeFormatter.HeadArrow = new GraphvizArrow(GraphvizArrowShape.Dot);
                };

            renderer.FormatVertex += fvertex;

            renderer.FormatEdge += Fedge;
            output = renderer.Write(fileName);
            return output;
        }
Пример #46
0
 /// <summary>
 /// Builds a new Graphviz writer of the graph g using the Stream s.
 /// </summary>
 /// <param name="g">Graph to visit.</param>
 /// <param name="prefix"></param>
 /// <param name="path">Path where files are to be created</param>
 /// <param name="imageType">image output type</param>
 public GraphvizAlgorithm(
     IVertexAndEdgeListGraph g,
     String prefix,
     String path,
     GraphvizImageType imageType
     )
 {
     if (g == null)
         throw new ArgumentNullException("g");
     m_VisitedGraph = g;
     m_StringWriter = null;
     m_Dot = new DotRenderer(prefix,path,imageType);
 }
Пример #47
0
        public void Render(string outputPath, GraphvizImageType imageType)
        {
            if (DebugSettings.GraphMethod != null && DebugSettings.GraphMethod != MethodCompileInfo.Method.ToString())
            {
                return;
            }
            GraphvizAlgorithm algorithm = new GraphvizAlgorithm(Graph);

            algorithm.GraphFormat.Label = MethodCompileInfo.Method.ToString();
            algorithm.CommonVertexFormat.Shape = GraphvizVertexShape.Circle;
            algorithm.CommonVertexFormat.Style = GraphvizVertexStyle.Filled;
            algorithm.CommonVertexFormat.FillColor = System.Drawing.Color.RoyalBlue;
            algorithm.CommonVertexFormat.Font = new System.Drawing.Font("Tahoma", 10);
            algorithm.CommonVertexFormat.FontColor = System.Drawing.Color.White;

            algorithm.CommonEdgeFormat.Dir = GraphvizEdgeDirection.None;
            algorithm.CommonEdgeFormat.Style = GraphvizEdgeStyle.Bold;

            algorithm.ImageType = imageType;

            algorithm.FormatVertex += new FormatVertexEventHandler(algorithm_FormatVertex);

            List<InterferenceGraphEdge> removedEdges = new List<InterferenceGraphEdge>();
            List<InterferenceGraphEdge> edges = new List<InterferenceGraphEdge>();
            foreach (QuickGraph.Concepts.IEdge edge in Graph.Edges)
            {
                edges.Add((InterferenceGraphEdge)edge);
            }
            foreach (InterferenceGraphEdge edge in edges)
            {
                if (Graph.ContainsEdge(edge.Target, edge.Source) && Graph.ContainsEdge(edge.Source, edge.Target))
                {
                    removedEdges.Add(edge);
                    Graph.RemoveEdge(edge);
                }
            }

            System.Drawing.Color[] colorList = new System.Drawing.Color[]{
                System.Drawing.Color.Red,
                System.Drawing.Color.Blue,
                System.Drawing.Color.Green,
                System.Drawing.Color.Orange,
                System.Drawing.Color.Black,
                System.Drawing.Color.Green,
                System.Drawing.Color.DarkGray,
                System.Drawing.Color.Orange,
                System.Drawing.Color.Navy,
                System.Drawing.Color.Brown,
                System.Drawing.Color.Purple,
                System.Drawing.Color.PowderBlue,
                System.Drawing.Color.Yellow,
                System.Drawing.Color.Magenta,
                System.Drawing.Color.Pink,
                System.Drawing.Color.LightBlue,
                System.Drawing.Color.LightGray
            };
            int increment = 0xffffff / MethodCompileInfo.MaxRegisters;
            for (int i = 1; i <= MethodCompileInfo.MaxRegisters; i++)
            {
                //ColorMapping[i] = colorList[i - 1];
                ColorMapping[i] = System.Drawing.Color.FromArgb(i * increment);
            }

            algorithm.Write(outputPath);

            foreach (InterferenceGraphEdge edge in removedEdges)
            {
                Graph.AddEdge(edge);
            }
        }
Пример #48
0
 /// <summary>
 /// Generates the dot code to be rendered with GraphViz
 /// </summary>
 /// <param name="imageType"></param>
 /// <returns>outputed file name</returns>
 public String Write(GraphvizImageType imageType)
 {
     m_Dot.ImageType = imageType;
     return Write();
 }
        /// <summary>
        /// Builds a new Graphviz writer of the graph g using the Stream s.
        /// </summary>
        /// <param name="g">Graph to visit.</param>
        /// <param name="path">Path where files are to be created</param>
        /// <param name="imageType">output image type</param>
        /// <exception cref="ArgumentNullException">g is a null reference</exception>
        /// <exception cref="ArgumentNullException">path is a null reference</exception>
        public GraphvizAlgorithm(
            IVertexAndEdgeListGraph g,
            String path,
            GraphvizImageType imageType
            )
        {
            if (g == null)
                throw new ArgumentNullException("g");
            if (path==null)
                throw new ArgumentNullException("path");
            m_VisitedGraph = g;
            m_StringWriter = null;
            m_Dot = new Dot(path);
            m_ImageType = imageType;

            clusterCount = 0;
            m_GraphFormat = new GraphvizGraph();

            m_CommonVertexFormat = new GraphvizVertex();
            m_CommonEdgeFormat = new GraphvizEdge();

            m_VertexFormat = new GraphvizVertex();
            m_EdgeFormat = new GraphvizEdge();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g"></param>
        public GraphvizAlgorithm(IVertexAndEdgeListGraph g)
        {
            if (g == null)
                throw new ArgumentNullException("g");
            m_VisitedGraph = g;
            m_StringWriter = null;
            m_Dot = new Dot();
            m_ImageType = GraphvizImageType.Png;

            m_GraphFormat = new GraphvizGraph();

            m_CommonVertexFormat = new GraphvizVertex();
            m_CommonEdgeFormat = new GraphvizEdge();

            m_VertexFormat = new GraphvizVertex();
            m_EdgeFormat = new GraphvizEdge();
        }
Пример #51
0
 /// <summary>
 /// Writes the dot code to the dotFileName and then executes dot on it.
 /// </summary>
 /// <param name="dotCode"></param>
 /// <param name="imageType"></param>
 /// <returns>output file name</returns>
 public String Render(
     String dotCode,
     GraphvizImageType imageType
     )
 {
     ImageType = imageType;
     return Render(dotCode);
 }
Пример #52
0
            public string Run(GraphvizImageType imageType, string dot, string outputFileName)
            {
                string output = outputFileName;
                File.WriteAllText(output, dot);

                // assumes dot.exe is on the path:
                var dotargs = string.Format(@"{0} -Tjpg -O", output);
                System.Diagnostics.Process.Start(@"C:\Program Files (x86)\Graphviz2.38\bin\dot.exe", dotargs);

                return output;
            }
Пример #53
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public DotRenderer()
 {
     Prefix="dot";
     Path="";
     m_ImageType = GraphvizImageType.Png;
 }
Пример #54
0
 /// <summary>
 /// Detailled constructor
 /// </summary>
 /// <param name="prefix"></param>
 /// <param name="path"></param>
 /// <param name="imageType"></param>
 public DotRenderer(String prefix,String path,GraphvizImageType imageType)
 {
     Prefix = prefix;
     Path = path;
     m_ImageType = imageType;
 }