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(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 Visualize(string solutionPath) { Tracer.Info("Vizualizing {0} ...", solutionPath); AdjacencyGraph graph = new AdjacencyGraph(new ReferenceVertexProvider(), new EdgeProvider(), false); Solution solution; Project proj = null; switch (Path.GetExtension(solutionPath)) { case ".sln": solution = Solution.FromFile(solutionPath); break; case ".csproj": solution = Solution.EmptySolution(); proj = Project.FromFile(solutionPath, solution); proj.Parse(); solution.Projects.Add(proj.Guid, proj); break; case ".vbproj": solution = Solution.EmptySolution(); proj = Project.FromFile(solutionPath, solution); proj.Parse(); solution.Projects.Add(proj.Guid, proj); break; /*case ".vcproj": * // This is broken, RelativePathToProject is relative from Solution folder * solution = Solution.EmptySolution(); * proj = Project.FromVCProjFile(solutionPath); * proj.ParseVCProj(); * solution.Projects.Add(proj.Guid, proj); * break;*/ default: MessageBox.Show(string.Format(CultureInfo.CurrentCulture, Resources.UnsupportedExtension, Path.GetExtension(solutionPath)), Resources.DependencyVisualizer, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } GraphvizAlgorithm svg = new GraphvizAlgorithm(graph, Resources.Dependencies, GraphvizImageType.Svg); GraphvizAlgorithm png = new GraphvizAlgorithm(graph, Resources.Dependencies, GraphvizImageType.Png); foreach (Project project in solution.Projects.Values) { AddProjectToGraph(project, graph); } Tracer.Info("Added {0} vertices to graph ...", (graph.VertexProvider as ReferenceVertexProvider).VertexCount); svg.WriteVertex += new VertexEventHandler(alg_WriteVertex); //svg.Write(Path.GetFileNameWithoutExtension(solutionPath)); svg.Write(proj.Name); png.WriteVertex += new VertexEventHandler(alg_WriteVertex); //png.Write(Path.GetFileNameWithoutExtension(solutionPath)); png.Write(proj.Name); }
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> /// 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); }
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> /// 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"); }
/// <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"); }
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"); }
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); }
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(); }