alpar@896: #include alpar@896: #include alpar@896: #include alpar@896: //#include alpar@896: #include "test_tools.h" alpar@896: alpar@896: using namespace std; alpar@896: using namespace hugo; alpar@896: alpar@896: alpar@896: alpar@896: bool passed = true; alpar@896: alpar@896: alpar@896: int main() alpar@896: { alpar@896: alpar@896: typedef ListGraph::Node Node; alpar@896: typedef ListGraph::Edge Edge; alpar@896: alpar@896: ListGraph graph; alpar@896: alpar@896: //Ahuja könyv példája alpar@896: alpar@896: Node s=graph.addNode(); alpar@896: Node v1=graph.addNode(); alpar@896: Node v2=graph.addNode(); alpar@896: Node v3=graph.addNode(); alpar@896: Node v4=graph.addNode(); alpar@896: Node v5=graph.addNode(); alpar@896: Node t=graph.addNode(); alpar@896: alpar@896: Edge s_v1=graph.addEdge(s, v1); alpar@896: Edge v1_v2=graph.addEdge(v1, v2); alpar@896: Edge s_v3=graph.addEdge(s, v3); alpar@896: Edge v2_v4=graph.addEdge(v2, v4); alpar@896: Edge v2_v5=graph.addEdge(v2, v5); alpar@896: Edge v3_v5=graph.addEdge(v3, v5); alpar@896: Edge v4_t=graph.addEdge(v4, t); alpar@896: Edge v5_t=graph.addEdge(v5, t); alpar@896: alpar@896: alpar@896: ListGraph::EdgeMap length(graph); alpar@896: alpar@896: length.set(s_v1, 6); alpar@896: length.set(v1_v2, 4); alpar@896: length.set(s_v3, 10); alpar@896: length.set(v2_v4, 5); alpar@896: length.set(v2_v5, 1); alpar@896: length.set(v3_v5, 5); alpar@896: length.set(v4_t, 8); alpar@896: length.set(v5_t, 8); alpar@896: alpar@896: std::cout << "Minlengthpaths algorithm test..." << std::endl; alpar@896: alpar@896: alpar@896: int k=3; alpar@896: MinLengthPaths< ListGraph, ListGraph::EdgeMap > alpar@896: surb_test(graph, length); alpar@896: alpar@896: check( surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46, alpar@896: "Two paths, total length should be 46"); alpar@896: alpar@896: check( surb_test.checkComplementarySlackness(), alpar@896: "Complementary slackness conditions are not met."); alpar@896: alpar@896: // typedef DirPath DPath; alpar@896: // DPath P(graph); alpar@896: alpar@896: /* alpar@896: surb_test.getPath(P,0); alpar@896: check(P.length() == 4, "First path should contain 4 edges."); alpar@896: cout<