コード例 #1
0
        public string Generate(IDotEngine dot, string outputFileName)
        {
            Contract.Requires(dot != null);
            Contract.Requires(!String.IsNullOrEmpty(outputFileName));

            var output = this.Generate();

            return(dot.Run(ImageType, Output.ToString(), outputFileName));
        }
コード例 #2
0
        public string Generate(IDotEngine dot, string outputFileName)
        {
            if (dot == null)
            {
                throw new ArgumentNullException("dot");
            }
            if (outputFileName == null)
            {
                throw new ArgumentNullException("outputFileName");
            }

            this.vertexIds.Clear();

            this.output = new StringWriter();

            // build vertex id map
            int i = 0;

            foreach (TVertex v in this.VisitedGraph.Vertices)
            {
                this.vertexIds.Add(v, i++);
            }

            Output.WriteLine("digraph G {");

            String gf = GraphFormat.ToDot();

            if (gf.Length > 0)
            {
                Output.WriteLine(gf);
            }
            String vf = CommonVertexFormat.ToDot();

            if (vf.Length > 0)
            {
                Output.WriteLine("node [{0}];", vf);
            }
            String ef = CommonEdgeFormat.ToDot();

            if (ef.Length > 0)
            {
                Output.WriteLine("edge [{0}];", ef);
            }

            // initialize vertex map
            IDictionary <TVertex, GraphColor> colors = new Dictionary <TVertex, GraphColor>();

            foreach (var v in VisitedGraph.Vertices)
            {
                colors[v] = GraphColor.White;
            }
            IDictionary <TEdge, GraphColor> edgeColors = new Dictionary <TEdge, GraphColor>();

            foreach (var e in VisitedGraph.Edges)
            {
                edgeColors[e] = GraphColor.White;
            }

            WriteVertices(colors, VisitedGraph.Vertices);
            WriteEdges(edgeColors, VisitedGraph.Edges);

            Output.WriteLine("}");

            return(dot.Run(ImageType, Output.ToString(), outputFileName));
        }