# HG changeset patch # User athos # Date 1083595360 0 # Node ID 60afd11e6cb3ea1f67fe46047a0efc32be1e15dd # Parent d5fe2f3f95fc63070e21a562210b09e1b6bee1bd xy_test added: it was not entirely useless, I found a mistake in xy.h diff -r d5fe2f3f95fc -r 60afd11e6cb3 src/work/athos/minlengthpaths.h --- a/src/work/athos/minlengthpaths.h Mon May 03 11:43:27 2004 +0000 +++ b/src/work/athos/minlengthpaths.h Mon May 03 14:42:40 2004 +0000 @@ -22,7 +22,7 @@ /// of minimal total length /// /// The class \ref hugo::MinLengthPaths "MinLengthPaths" implements - /// an algorithm which finds k edge-disjoint paths + /// an algorithm for finding k edge-disjoint paths /// from a given source node to a given target node in an /// edge-weighted directed graph having minimal total weigth (length). /// diff -r d5fe2f3f95fc -r 60afd11e6cb3 src/work/athos/minlengthpaths_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/athos/minlengthpaths_test.cc Mon May 03 14:42:40 2004 +0000 @@ -0,0 +1,128 @@ +// -*- c++ -*- +//#include +//#include +//#include + +#include +#include + +using namespace hugo; + + +int main() +{ + + + typedef ListGraph::Node Node; + typedef ListGraph::Edge Edge; + + ListGraph graph; + + /* + //Marci példája + + + NodeIt s=graph.addNode(); + NodeIt v1=graph.addNode(); + NodeIt v2=graph.addNode(); + NodeIt v3=graph.addNode(); + NodeIt v4=graph.addNode(); + NodeIt t=graph.addNode(); + + + EdgeIt s_v1=graph.addEdge(s, v1); + EdgeIt s_v2=graph.addEdge(s, v2); + EdgeIt v1_v2=graph.addEdge(v1, v2); + EdgeIt v2_v1=graph.addEdge(v2, v1); + EdgeIt v1_v3=graph.addEdge(v1, v3); + EdgeIt v3_v2=graph.addEdge(v3, v2); + EdgeIt v2_v4=graph.addEdge(v2, v4); + EdgeIt v4_v3=graph.addEdge(v4, v3); + EdgeIt v3_t=graph.addEdge(v3, t); + EdgeIt v4_t=graph.addEdge(v4, t); + + ListGraph::EdgeMap length(graph); + + length.set(s_v1, 16); + length.set(s_v2, 13); + length.set(v1_v2, 10); + length.set(v2_v1, 4); + length.set(v1_v3, 12); + length.set(v3_v2, 9); + length.set(v2_v4, 14); + length.set(v4_v3, 7); + length.set(v3_t, 20); + length.set(v4_t, 4); + */ + + + //Ahuja könyv példája + + Node s=graph.addNode(); + Node v2=graph.addNode(); + Node v3=graph.addNode(); + Node v4=graph.addNode(); + Node v5=graph.addNode(); + Node t=graph.addNode(); + + Edge s_v2=graph.addEdge(s, v2); + Edge s_v3=graph.addEdge(s, v3); + Edge v2_v4=graph.addEdge(v2, v4); + Edge v2_v5=graph.addEdge(v2, v5); + Edge v3_v5=graph.addEdge(v3, v5); + Edge v4_t=graph.addEdge(v4, t); + Edge v5_t=graph.addEdge(v5, t); + + //Kis modositas + //edge_iterator v2_s=graph.add_edge(v2, s); + + ListGraph::EdgeMap length(graph); + + length.set(s_v2, 10); + length.set(s_v3, 10); + length.set(v2_v4, 5); + length.set(v2_v5, 8); + length.set(v3_v5, 5); + length.set(v4_t, 8); + length.set(v5_t, 8); + + //Kis modositas + //length.put(v2_s, 100); + + + + + /*Egyszerű példa + NodeIt s=flow_test.add_node(); + NodeIt v1=flow_test.add_node(); + NodeIt v2=flow_test.add_node(); + NodeIt t=flow_test.add_node(); + + node_property_vector node_name(flow_test); + node_name.put(s, "s"); + node_name.put(v1, "v1"); + node_name.put(v2, "v2"); + node_name.put(t, "t"); + + edge_iterator s_v1=flow_test.add_edge(s, v1); + edge_iterator v1_v2=flow_test.add_edge(v1, v2); + edge_iterator v2_t=flow_test.add_edge(v2, t); + + edge_property_vector length(flow_test); + + length.put(s_v1, 16); + length.put(v1_v2, 10); + length.put(v2_t, 4); + */ + + std::cout << "Suurballe algorithm test..." << std::endl; + + + int k=3; + MinLengthPaths > + surb_test(graph, length); + std::cout << surb_test.run(s,t,k) << std::endl; + + + return 0; +} diff -r d5fe2f3f95fc -r 60afd11e6cb3 src/work/athos/xy/xy.cc --- a/src/work/athos/xy/xy.cc Mon May 03 11:43:27 2004 +0000 +++ b/src/work/athos/xy/xy.cc Mon May 03 14:42:40 2004 +0000 @@ -1,7 +1,10 @@ #include #include +#include using namespace std; using namespace hugo; + + int main() { diff -r d5fe2f3f95fc -r 60afd11e6cb3 src/work/athos/xy/xy_test.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/athos/xy/xy_test.cc Mon May 03 14:42:40 2004 +0000 @@ -0,0 +1,54 @@ +#include +#include +using namespace std; +using namespace hugo; + +bool passed = true; + +void check(bool rc) { + passed = passed && rc; + if(!rc) { + cout << "Test failed!" << endl; + } +} + + + +int main() +{ + + + + typedef xy XY; + + XY seged; + XY a(1,2); + XY b(3,4); + + seged = a+b; + check(seged.x==4 && seged.y==6); + + seged = a-b; + check(seged.x==-1 && seged.y==-1); + + check(a.normSquare()==5); + check(a*b==11); + + int l=2; + seged = a*l; + check(seged.x==2 && seged.y==4); + + seged = b/l; + check(seged.x==1 && seged.y==2); + + typedef BoundingBox BB; + BB doboz1; + doboz1 += a; + doboz1 += b; + + cout << (passed ? "All tests passed." : "Some of the tests failed!!!") + << endl; + + return passed ? 0 : 1; + +}