public void DirectedSparseGraphWithoutPath() { TestCase testCase = new TestCase(); testCase.AddVertex("n1") .AddVertex("n2") .AddVertex("n3") .AddVertex("n4") .AddVertex("n5") .AddVertex("n6"); testCase.AddDirectedEdge("n1", "n2", 10) .AddDirectedEdge("n2", "n3", 8) .AddDirectedEdge("n3", "n4", 11) .AddDirectedEdge("n4", "n5", 6) .AddDirectedEdge("n5", "n6", 9) .AddDirectedEdge("n1", "n6", 3) .AddDirectedEdge("n2", "n6", 5) .AddDirectedEdge("n3", "n6", 18) .AddDirectedEdge("n3", "n5", 21); var tcp = new TSP <String, EquatableEdge <String>, BidirectionalGraph <String, EquatableEdge <String> > >(testCase.Graph, testCase.GetFuncWeights()); tcp.Compute(); Assert.AreEqual(tcp.BestCost, Double.PositiveInfinity); Assert.IsTrue(tcp.ResultPath == null); }
public void DirectedSparseGraph() { TestCase testCase = new TestCase(); testCase.AddVertex("n1") .AddVertex("n2") .AddVertex("n3") .AddVertex("n4") .AddVertex("n5") .AddVertex("n6"); testCase.AddDirectedEdge("n1", "n2", 10) .AddDirectedEdge("n2", "n3", 8) .AddDirectedEdge("n3", "n4", 11) .AddDirectedEdge("n4", "n5", 6) .AddDirectedEdge("n5", "n6", 9) .AddDirectedEdge("n1", "n6", 3) .AddDirectedEdge("n2", "n6", 5) .AddDirectedEdge("n3", "n6", 18) .AddDirectedEdge("n3", "n5", 21) .AddDirectedEdge("n6", "n1", 1); var tcp = new TSP <String, EquatableEdge <String>, BidirectionalGraph <String, EquatableEdge <String> > >(testCase.Graph, testCase.GetFuncWeights()); tcp.Compute(); Assert.AreEqual(tcp.BestCost, 45); Assert.IsFalse(tcp.ResultPath.IsDirectedAcyclicGraph()); }
public void DirectedSparseGraphWithoutPath() { TestCase testCase = new TestCase(); testCase.AddVertex("n1") .AddVertex("n2") .AddVertex("n3") .AddVertex("n4") .AddVertex("n5") .AddVertex("n6"); testCase.AddDirectedEdge("n1", "n2", 10) .AddDirectedEdge("n2", "n3", 8) .AddDirectedEdge("n3", "n4", 11) .AddDirectedEdge("n4", "n5", 6) .AddDirectedEdge("n5", "n6", 9) .AddDirectedEdge("n1", "n6", 3) .AddDirectedEdge("n2", "n6", 5) .AddDirectedEdge("n3", "n6", 18) .AddDirectedEdge("n3", "n5", 21); var tcp = new TSP<String, EquatableEdge<String>, BidirectionalGraph<String, EquatableEdge<String>>>(testCase.Graph, testCase.GetFuncWeights()); tcp.Compute(); Assert.AreEqual(tcp.BestCost, Double.PositiveInfinity); Assert.IsTrue(tcp.ResultPath == null); }
public static TestCase completeGraphTestCase(int vertices, int maxWeight) { var random = new Random(); TestCase testCase = new TestCase(); for (int i = 0; i < vertices; ++i) { testCase.AddVertex("n" + i); } foreach (var v1 in testCase.Graph.Vertices) { foreach (var v2 in testCase.Graph.Vertices) { testCase.AddDirectedEdge(v1, v2, random.Next(maxWeight)); } } return(testCase); }
public void DirectedSparseGraph() { TestCase testCase = new TestCase(); testCase.AddVertex("n1") .AddVertex("n2") .AddVertex("n3") .AddVertex("n4") .AddVertex("n5") .AddVertex("n6"); testCase.AddDirectedEdge("n1", "n2", 10) .AddDirectedEdge("n2", "n3", 8) .AddDirectedEdge("n3", "n4", 11) .AddDirectedEdge("n4", "n5", 6) .AddDirectedEdge("n5", "n6", 9) .AddDirectedEdge("n1", "n6", 3) .AddDirectedEdge("n2", "n6", 5) .AddDirectedEdge("n3", "n6", 18) .AddDirectedEdge("n3", "n5", 21) .AddDirectedEdge("n6", "n1", 1); var tcp = new TSP<String, EquatableEdge<String>, BidirectionalGraph<String, EquatableEdge<String>>>(testCase.Graph, testCase.GetFuncWeights()); tcp.Compute(); Assert.AreEqual(tcp.BestCost, 45); Assert.IsFalse(tcp.ResultPath.IsDirectedAcyclicGraph()); }
public static TestCase completeGraphTestCase(int vertices, int maxWeight) { var random = new Random(); TestCase testCase = new TestCase(); for (int i = 0; i < vertices; ++i) { testCase.AddVertex("n" + i); } foreach (var v1 in testCase.Graph.Vertices) { foreach (var v2 in testCase.Graph.Vertices) { testCase.AddDirectedEdge(v1, v2, random.Next(maxWeight)); } } return testCase; }