public void Run() { // create an adjacency graph AdjacencyGraph g = new AdjacencyGraph( new NamedVertexProvider(), new NamedEdgeProvider(), true ); // create a clustered graph ClusteredAdjacencyGraph cg = new ClusteredAdjacencyGraph(g); // adding some vertices to the main graph NamedVertex a = cg.AddVertex() as NamedVertex; a.Name="a"; NamedVertex b = cg.AddVertex() as NamedVertex; b.Name="b"; NamedVertex c = cg.AddVertex() as NamedVertex; c.Name="c"; NamedEdge ab = cg.AddEdge(a,b) as NamedEdge; ab.Name="ab"; NamedEdge ac = cg.AddEdge(a,c) as NamedEdge; ac.Name="ac"; // adding a cluster ClusteredAdjacencyGraph cg1 = cg.AddCluster(); // adding vertices and edges to the cluster NamedVertex d = cg1.AddVertex() as NamedVertex; d.Name="d"; NamedVertex e = cg1.AddVertex() as NamedVertex; e.Name="e"; NamedVertex f = cg1.AddVertex() as NamedVertex; f.Name="f"; NamedEdge de = cg1.AddEdge(d,e) as NamedEdge; de.Name="de"; NamedEdge df = cg1.AddEdge(d,f) as NamedEdge; df.Name="df"; // adding a second cluster ClusteredAdjacencyGraph cg2 = cg.AddCluster(); // adding vertices NamedVertex h = cg2.AddVertex() as NamedVertex; h.Name="h"; NamedVertex i = cg2.AddVertex() as NamedVertex; i.Name="i"; NamedEdge hi = cg2.AddEdge(h,i) as NamedEdge; hi.Name="hi"; // adding a sub-sub-cluster ClusteredAdjacencyGraph cg21 = cg2.AddCluster(); // adding vertices NamedVertex k = cg21.AddVertex() as NamedVertex; k.Name="k"; NamedVertex l = cg21.AddVertex() as NamedVertex; l.Name="l"; NamedEdge ak = cg.AddEdge(a,k) as NamedEdge; ak.Name="ak"; NamedEdge kl = cg21.AddEdge(k,l) as NamedEdge; kl.Name="kl"; // interconnecting NamedEdge cd = cg.AddEdge(c,d) as NamedEdge; cd.Name="cd"; NamedEdge bh = cg.AddEdge(b,h) as NamedEdge; bh.Name="bh"; NamedEdge ei = cg.AddEdge(e,i) as NamedEdge; ei.Name="ei"; GraphvizAlgorithm gw = new GraphvizAlgorithm( cg, "../cluster", GraphvizImageType.Svgz ); gw.FormatVertex += new FormatVertexEventHandler(this.FormatVertex); gw.FormatEdge += new FormatEdgeEventHandler(this.FormatEdge); gw.Write("cluster"); cg2.Colapsed = true; gw.Write("cluster_collapsed"); }
/// <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); }
public MaximumFlowDemo() { graph = new AdjacencyGraph( new NamedVertexProvider(), new EdgeProvider(), true); s = (NamedVertex)graph.AddVertex(); s.Name = "s"; x = (NamedVertex)graph.AddVertex(); x.Name = "x"; v = (NamedVertex)graph.AddVertex(); v.Name = "v"; w = (NamedVertex)graph.AddVertex(); w.Name = "w"; t = (NamedVertex)graph.AddVertex(); t.Name = "t"; sx = graph.AddEdge(s, x); capacities[sx] = 5; sv = graph.AddEdge(s, v); capacities[sv] = 7; xv = graph.AddEdge(x, v); capacities[xv] = 3; xw = graph.AddEdge(x, w); capacities[xw] = 7; wv = graph.AddEdge(w, v); capacities[wv] = 5; wt = graph.AddEdge(w, t); capacities[wt] = 4; vt = graph.AddEdge(v, t); capacities[vt] = 6; this.graphviz = new GraphvizAlgorithm(this.graph); this.graphviz.ImageType = NGraphviz.Helpers.GraphvizImageType.Svg; this.graphviz.GraphFormat.RankDirection = NGraphviz.Helpers.GraphvizRankDirection.LR; this.graphviz.FormatVertex+=new FormatVertexEventHandler(graphviz_FormatVertex); this.graphviz.FormatEdge+=new FormatEdgeEventHandler(graphviz_FormatEdge); this.reversedEdgeAugmentor = new ReversedEdgeAugmentorAlgorithm(this.graph); this.reversedEdgeAugmentor.ReversedEdgeAdded += new EdgeEventHandler(reversedEdgeAugmentor_ReversedEdgeAdded); }
public void Test(IVertexAndEdgeListGraph g, IVertex root) { this.root = root; RandomWalkAlgorithm walker = new RandomWalkAlgorithm(g); walker.TreeEdge +=new EdgeEventHandler(walker_TreeEdge); walker.Generate(root,50); BidirectionalAdaptorGraph bg = new BidirectionalAdaptorGraph(g); ReversedBidirectionalGraph rg = new ReversedBidirectionalGraph(bg); CyclePoppingRandomTreeAlgorithm pop = new CyclePoppingRandomTreeAlgorithm(rg); pop.InitializeVertex +=new VertexEventHandler(this.InitializeVertex); pop.FinishVertex +=new VertexEventHandler(this.FinishVertex); pop.TreeEdge += new EdgeEventHandler(this.TreeEdge); pop.InitializeVertex +=new VertexEventHandler(vis.InitializeVertex); pop.TreeEdge += new EdgeEventHandler(vis.TreeEdge); pop.ClearTreeVertex += new VertexEventHandler(vis.ClearTreeVertex); pop.RandomTreeWithRoot(root); // plot tree... GraphvizAlgorithm gv = new GraphvizAlgorithm(g,".",GraphvizImageType.Svg); gv.FormatEdge +=new FormatEdgeEventHandler(this.FormatEdge); gv.FormatVertex +=new FormatVertexEventHandler(this.FormatVertex); gv.Write("randomtree"); }
public void DrawGraph(IVertexAndEdgeListGraph g, string fileName) { GraphvizAlgorithm gv = new GraphvizAlgorithm(g); gv.FormatVertex+=new FormatVertexEventHandler(gv_FormatVertex); gv.FormatEdge+=new FormatEdgeEventHandler(gv_FormatEdge); System.Diagnostics.Process.Start(gv.Write(fileName)); }
/// <summary> /// Default constructor /// </summary> public GraphvizControl() { m_Algo = new GraphvizAlgorithm( new AdjacencyGraph(new VertexAndEdgeProvider(),true) ); RelativePath = ""; m_TimeOut = new TimeSpan(0,0,15,0,0); m_ImageSize = new Size(0,0); m_CustomCacheKey = null; }
/// <summary> /// entry point for the application. /// </summary> public void Test(string outputImageFolder) { AdjacencyGraph g = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true); MyVertex[] v = new MyVertex[12]; for( int i=0; i<12;i++) { v[i] = (MyVertex) g.AddVertex(); v[i].Name = "Vertex " + i; v[i].Value = i; } g.AddEdge(v[0], v[1]); g.AddEdge(v[1], v[2]); g.AddEdge(v[2], v[3]); g.AddEdge(v[3], v[0]); g.AddEdge(v[2], v[0]); g.AddEdge(v[4], v[5]); g.AddEdge(v[5], v[6]); g.AddEdge(v[6], v[7]); g.AddEdge(v[7], v[4]); g.AddEdge(v[2], v[5]); g.AddEdge(v[8], v[9]); g.AddEdge(v[9], v[8]); g.AddEdge(v[10], v[11]); g.AddEdge(v[11], v[10]); g.AddEdge(v[2], v[9]); g.AddEdge(v[9], v[10]); GraphvizAlgorithm renderer = new GraphvizAlgorithm(g,outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg); renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph); renderer.Write("Original_Graph.jpeg"); CondensationGraphAlgorithm cgalgo = new CondensationGraphAlgorithm( g ); cgalgo.InitCondensationGraphVertex += new CondensationGraphVertexEventHandler(CGVertexHandler); AdjacencyGraph cg = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true); cgalgo.Create(cg); // Render the Condensation Graph renderer = new GraphvizAlgorithm(cg, outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg); renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph); renderer.Write("CG.jpeg"); }
public WixRenderer() { this.graph = new AdjacencyGraph( new CustomVertexProvider(), new CustomEdgeProvider(), true ); this.graphviz = new GraphvizAlgorithm(this.graph); this.wix = null; this.graphviz.ImageType = NGraphviz.Helpers.GraphvizImageType.Svg; this.graphviz.CommonEdgeFormat.Font = new Font("Tahoma", 8.25f); this.graphviz.CommonVertexFormat.Font = new Font("Tahoma", 8.25f); this.graphviz.CommonVertexFormat.Style = NGraphviz.Helpers.GraphvizVertexStyle.Filled; this.graphviz.CommonVertexFormat.FillColor = Color.LightYellow; this.graphviz.CommonVertexFormat.Shape = NGraphviz.Helpers.GraphvizVertexShape.Box; this.graphviz.FormatVertex+=new FormatVertexEventHandler(graphviz_FormatVertex); this.visitor = new GraphPopulatorWixVisitor(this); }
/// <summary> /// Entry point for the application. /// </summary> public static void Test(string outputImageFolder) { AdjacencyGraph g = new AdjacencyGraph( new MyVertexProvider(), new EdgeProvider(), true); MyVertex[] v = new MyVertex[12]; for( int i=0; i<12;i++) { v[i] = (MyVertex) g.AddVertex(); v[i].Name = "Vertex " + i; v[i].Value = i; } g.AddEdge(v[0], v[1]); g.AddEdge(v[1], v[2]); g.AddEdge(v[2], v[3]); g.AddEdge(v[3], v[0]); g.AddEdge(v[2], v[0]); g.AddEdge(v[4], v[5]); g.AddEdge(v[5], v[6]); g.AddEdge(v[6], v[7]); g.AddEdge(v[7], v[4]); g.AddEdge(v[2], v[5]); g.AddEdge(v[8], v[9]); g.AddEdge(v[9], v[8]); g.AddEdge(v[10], v[11]); g.AddEdge(v[11], v[10]); g.AddEdge(v[2], v[9]); g.AddEdge(v[9], v[10]); GraphvizAlgorithm renderer = new GraphvizAlgorithm(g,outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg); renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph); renderer.Write("Original_Graph.jpeg"); TransitiveClosureAlgorithm tcalgo = new TransitiveClosureAlgorithm(g); AdjacencyGraph tc = new AdjacencyGraph(new MyVertexProvider(), new EdgeProvider(), true); tcalgo.InitTransitiveClosureVertex += new TransitiveClosureVertexEventHandler(MapTCVertex); tcalgo.ExamineEdge += new EdgeEventHandler(InitEdge); tcalgo.Create(tc); renderer = new GraphvizAlgorithm(tc, outputImageFolder, NGraphviz.Helpers.GraphvizImageType.Jpeg); renderer.FormatVertex += new FormatVertexEventHandler(FormatGraph); renderer.Write("TC.jpeg"); }
/// <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"></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); }
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); }
/// <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); }
public PetriNetRenderer(PetriGraph net) { this.algo=new GraphvizAlgorithm(net); this.algo.ImageType = GraphvizImageType.Png; this.algo.FormatVertex+=new FormatVertexEventHandler(algo_FormatVertex); }
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); } }
public void OutputAllMergedActions( EdgePredecessorRecorderVisitor erec, GraphvizAlgorithm gw, string path) { int i=1000; Console.WriteLine("All paths (merged):"); foreach(EdgeCollection ec in erec.AllMergedPaths()) { CurrentEdgePath = ec; gw.Write(String.Format("path-merged{1}",path,i)); foreach(IEdge edge in ec) { Console.WriteLine("{0}->{1}, {2}", ((NamedVertex)edge.Source).Name, ((NamedVertex)edge.Target).Name, ((NamedEdge)edge).Name ); } ++i; Console.WriteLine(); } CurrentEdgePath=null; }
public void Test() { // create a new adjacency graph AdjacencyGraph g = new AdjacencyGraph(new VertexAndEdgeProvider(), false); // adding files and storing names IVertex zig_cpp = g.AddVertex(); Names[zig_cpp]="zip.cpp"; IVertex boz_h = g.AddVertex(); Names[boz_h]="boz.h"; IVertex zag_cpp = g.AddVertex(); Names[zag_cpp]="zag.cpp"; IVertex yow_h = g.AddVertex(); Names[yow_h]="yow.h"; IVertex dax_h = g.AddVertex(); Names[dax_h]="dax.h"; IVertex bar_cpp = g.AddVertex(); Names[bar_cpp]="bar.cpp"; IVertex zow_h = g.AddVertex(); Names[zow_h]="zow.h"; IVertex foo_cpp = g.AddVertex(); Names[foo_cpp]="foo.cpp"; IVertex zig_o = g.AddVertex(); Names[zig_o]="zig.o"; IVertex zag_o = g.AddVertex(); Names[zag_o]="zago"; IVertex bar_o = g.AddVertex(); Names[bar_o]="bar.o"; IVertex foo_o = g.AddVertex(); Names[foo_o]="foo.o"; IVertex libzigzag_a = g.AddVertex();Names[libzigzag_a]="libzigzig.a"; IVertex libfoobar_a = g.AddVertex();Names[libfoobar_a]="libfoobar.a"; IVertex killerapp = g.AddVertex(); Names[killerapp]="killerapp"; // adding dependencies g.AddEdge(dax_h, foo_cpp); g.AddEdge(dax_h, bar_cpp); g.AddEdge(dax_h, yow_h); g.AddEdge(yow_h, bar_cpp); g.AddEdge(yow_h, zag_cpp); g.AddEdge(boz_h, bar_cpp); g.AddEdge(boz_h, zig_cpp); g.AddEdge(boz_h, zag_cpp); g.AddEdge(zow_h, foo_cpp); g.AddEdge(foo_cpp, foo_o); g.AddEdge(foo_o, libfoobar_a); g.AddEdge(bar_cpp, bar_o); g.AddEdge(bar_o, libfoobar_a); g.AddEdge(libfoobar_a, libzigzag_a); g.AddEdge(zig_cpp, zig_o); g.AddEdge(zig_o, libzigzag_a); g.AddEdge(zag_cpp, zag_o); g.AddEdge(zag_o, libzigzag_a); g.AddEdge(libzigzag_a, killerapp); // outputing graph to png GraphvizAlgorithm gw = new GraphvizAlgorithm( g, // graph to draw "filedependency", // output file prefix ".", // output file path GraphvizImageType.Png // output file type ); // outputing to graph. gw.Write(); // attaching the file name outputer... gw.WriteVertex += new VertexHandler(this.WriteVertex); gw.Write(); }
public PetriNetRenderer(PetriGraph net) { this.algo = new GraphvizAlgorithm(net); this.algo.ImageType = GraphvizImageType.Png; this.algo.FormatVertex += new FormatVertexEventHandler(algo_FormatVertex); }
public void Test() { // create a new adjacency graph AdjacencyGraph g = new AdjacencyGraph(false); // adding files and storing names IVertex boz_h = g.AddVertex(); Names[boz_h]="boz.h"; IVertex zag_cpp = g.AddVertex(); Names[zag_cpp]="zag.cpp"; IVertex yow_h = g.AddVertex(); Names[yow_h]="yow.h"; IVertex dax_h = g.AddVertex(); Names[dax_h]="dax.h"; IVertex bar_cpp = g.AddVertex(); Names[bar_cpp]="bar.cpp"; IVertex zow_h = g.AddVertex(); Names[zow_h]="zow.h"; IVertex foo_cpp = g.AddVertex(); Names[foo_cpp]="foo.cpp"; IVertex zig_o = g.AddVertex(); Names[zig_o]="zig.o"; IVertex zag_o = g.AddVertex(); Names[zag_o]="zago"; IVertex bar_o = g.AddVertex(); Names[bar_o]="bar.o"; IVertex foo_o = g.AddVertex(); Names[foo_o]="foo.o"; IVertex libzigzag_a = g.AddVertex();Names[libzigzag_a]="libzigzig.a"; IVertex libfoobar_a = g.AddVertex();Names[libfoobar_a]="libfoobar.a"; IVertex killerapp = g.AddVertex(); Names[killerapp]="killerapp"; IVertex zig_cpp = g.AddVertex(); Names[zig_cpp]="zip.cpp"; // adding dependencies g.AddEdge(dax_h, foo_cpp); g.AddEdge(dax_h, bar_cpp); g.AddEdge(dax_h, yow_h); g.AddEdge(yow_h, bar_cpp); g.AddEdge(yow_h, zag_cpp); g.AddEdge(boz_h, bar_cpp); g.AddEdge(boz_h, zig_cpp); g.AddEdge(boz_h, zag_cpp); g.AddEdge(zow_h, foo_cpp); g.AddEdge(foo_cpp, foo_o); g.AddEdge(foo_o, libfoobar_a); g.AddEdge(bar_cpp, bar_o); g.AddEdge(bar_o, libfoobar_a); g.AddEdge(libfoobar_a, libzigzag_a); g.AddEdge(zig_cpp, zig_o); g.AddEdge(zig_o, libzigzag_a); g.AddEdge(zag_cpp, zag_o); g.AddEdge(zag_o, libzigzag_a); g.AddEdge(libzigzag_a, killerapp); Console.WriteLine("Leaves"); foreach(IVertex v in AlgoUtility.Sinks(g)) { Console.WriteLine(Names[v]); } Console.WriteLine("Leaves of zag_o"); foreach(IVertex v in AlgoUtility.Sinks(g,zag_o)) { Console.WriteLine(Names[v]); } // outputing graph to png GraphvizAlgorithm gw = new GraphvizAlgorithm( g, // graph to draw ".", // output file path GraphvizImageType.Png // output file type ); // outputing to graph. gw.Write("filedependency"); // adding custom vertex settings gw.FormatVertex+=new FormatVertexEventHandler(gw_FormatVertex); gw.Write("fp"); }
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; }
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; }
/// <summary> /// Renders action graph /// </summary> /// <param name="g"></param> /// <param name="path"></param> /// <returns></returns> public GraphvizAlgorithm RenderActions(IVertexAndEdgeListGraph g, string path) { // outputing graph to png GraphvizAlgorithm gw = new GraphvizAlgorithm( g, // graph to draw path, // output file path GraphvizImageType.Png // output file type ); gw.FormatVertex += new FormatVertexEventHandler(this.FormatVertex); gw.FormatEdge += new FormatEdgeEventHandler(this.FormatEdge); gw.Write("actions"); return gw; }