public static BidirectionalGraph <TVertex, TEdge> ComputeTransitiveClosure <TVertex, TEdge>( this BidirectionalGraph <TVertex, TEdge> visitedGraph, Func <TVertex, TVertex, TEdge> createEdge ) where TEdge : IEdge <TVertex> { var algo = new TransitiveClosureAlgorithm <TVertex, TEdge>(visitedGraph, createEdge); algo.Compute(); return(algo.TransitiveClosure); }
/// <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 VertexListEnumerator(TransitiveClosureAlgorithm.VertexListMatrix arg) { this.it = arg.GetEnumerator(); }