alpar@906: /* -*- C++ -*- alpar@921: * src/test/suurballe_test.cc - Part of LEMON, a generic C++ optimization library alpar@906: * alpar@1164: * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@906: * (Egervary Combinatorial Optimization Research Group, EGRES). alpar@906: * alpar@906: * Permission to use, modify and distribute this software is granted alpar@906: * provided that this copyright notice appears in all copies. For alpar@906: * precise terms see the accompanying LICENSE file. alpar@906: * alpar@906: * This software is provided "AS IS" with no warranty of any kind, alpar@906: * express or implied, and with no claim as to its suitability for any alpar@906: * purpose. alpar@906: * alpar@906: */ alpar@906: alpar@899: #include alpar@921: #include alpar@921: #include alpar@899: //#include alpar@899: #include "test_tools.h" alpar@899: alpar@921: using namespace lemon; alpar@899: alpar@899: alpar@899: bool passed = true; alpar@899: alpar@899: alpar@899: int main() alpar@899: { marci@941: typedef ListGraph Graph; marci@941: typedef Graph::Node Node; marci@941: typedef Graph::Edge Edge; alpar@899: marci@941: Graph graph; alpar@899: alpar@899: //Ahuja könyv példája alpar@899: alpar@899: Node s=graph.addNode(); alpar@899: Node v1=graph.addNode(); alpar@899: Node v2=graph.addNode(); alpar@899: Node v3=graph.addNode(); alpar@899: Node v4=graph.addNode(); alpar@899: Node v5=graph.addNode(); alpar@899: Node t=graph.addNode(); alpar@899: alpar@899: Edge s_v1=graph.addEdge(s, v1); alpar@899: Edge v1_v2=graph.addEdge(v1, v2); alpar@899: Edge s_v3=graph.addEdge(s, v3); alpar@899: Edge v2_v4=graph.addEdge(v2, v4); alpar@899: Edge v2_v5=graph.addEdge(v2, v5); alpar@899: Edge v3_v5=graph.addEdge(v3, v5); alpar@899: Edge v4_t=graph.addEdge(v4, t); alpar@899: Edge v5_t=graph.addEdge(v5, t); alpar@899: alpar@899: marci@941: Graph::EdgeMap length(graph); alpar@899: alpar@899: length.set(s_v1, 6); alpar@899: length.set(v1_v2, 4); alpar@899: length.set(s_v3, 10); alpar@899: length.set(v2_v4, 5); alpar@899: length.set(v2_v5, 1); alpar@899: length.set(v3_v5, 5); alpar@899: length.set(v4_t, 8); alpar@899: length.set(v5_t, 8); alpar@899: alpar@899: std::cout << "Minlengthpaths algorithm test..." << std::endl; alpar@899: alpar@899: alpar@899: int k=3; marci@941: Suurballe< Graph, Graph::EdgeMap > marci@941: surb_test(graph, length, s, t); alpar@899: marci@941: check( surb_test.run(k) == 2 && surb_test.totalLength() == 46, alpar@899: "Two paths, total length should be 46"); alpar@899: alpar@899: check( surb_test.checkComplementarySlackness(), alpar@899: "Complementary slackness conditions are not met."); alpar@899: marci@941: // typedef DirPath DPath; alpar@899: // DPath P(graph); alpar@899: alpar@899: /* alpar@899: surb_test.getPath(P,0); alpar@899: check(P.length() == 4, "First path should contain 4 edges."); marci@941: std::cout<