public void Constructor() { var graph = new BidirectionalGraph <int, Edge <int> >(); var algorithm = new TransitiveClosureAlgorithm <int, Edge <int> >(graph, (v1, v2) => new Edge <int>(v1, v2)); AssertAlgorithmState(algorithm, graph); Assert.IsNotNull(algorithm.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"); }