alpar@906: /* -*- C++ -*- alpar@906: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1359: * (Egervary Research Group on Combinatorial Optimization, 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: hegyi@820: #include hegyi@820: #include deba@2247: klao@959: #include deba@2247: #include deba@2247: alpar@921: #include alpar@921: #include hegyi@820: deba@2247: #include "test_tools.h" deba@2247: hegyi@820: using namespace std; alpar@921: using namespace lemon; hegyi@820: deba@2247: void check_concepts() { deba@2247: checkConcept, deba@2247: concept::Path >(); deba@2247: checkConcept, deba@2247: Path >(); deba@2247: checkConcept, Path >(); hegyi@820: } hegyi@820: deba@2247: int main() { deba@2247: check_concepts(); deba@2247: deba@2247: ListGraph g; deba@2247: deba@2247: ListGraph::Node n1 = g.addNode(); deba@2247: ListGraph::Node n2 = g.addNode(); deba@2247: ListGraph::Node n3 = g.addNode(); deba@2247: ListGraph::Node n4 = g.addNode(); deba@2247: ListGraph::Node n5 = g.addNode(); deba@2247: deba@2247: ListGraph::Edge e1 = g.addEdge(n1, n2); deba@2247: ListGraph::Edge e2 = g.addEdge(n2, n3); deba@2247: ListGraph::Edge e3 = g.addEdge(n3, n4); deba@2247: ListGraph::Edge e4 = g.addEdge(n4, n5); deba@2247: ListGraph::Edge e5 = g.addEdge(n5, n1); hegyi@820: deba@2247: { deba@2247: Path p(g); deba@2247: deba@2247: check(p.empty(), "Wrong Path"); deba@2247: check(p.length() == 0, "Wrong Path"); deba@2247: deba@2247: { deba@2247: Path::Builder b(p); deba@2247: b.setStartNode(n3); deba@2247: b.commit(); deba@2247: } deba@2247: deba@2247: check(!p.empty(), "Wrong Path"); deba@2247: check(p.length() == 0, "Wrong Path"); deba@2247: check(p.source() == n3, "Wrong Path"); deba@2247: check(p.target() == n3, "Wrong Path"); deba@2247: deba@2247: { deba@2247: Path::Builder b(p); deba@2247: b.pushBack(e3); deba@2247: b.pushBack(e4); deba@2247: b.pushFront(e2); deba@2247: b.commit(); deba@2247: } deba@2247: deba@2247: check(!p.empty(), "Wrong Path"); deba@2247: check(p.length() == 3, "Wrong Path"); deba@2247: check(p.source() == n2, "Wrong Path"); deba@2247: check(p.target() == n5, "Wrong Path"); deba@2247: deba@2247: { deba@2247: Path::NodeIt it(p); deba@2247: check((ListGraph::Node)it == n2, "Wrong Path"); ++it; deba@2247: check((ListGraph::Node)it == n3, "Wrong Path"); ++it; deba@2247: check((ListGraph::Node)it == n4, "Wrong Path"); ++it; deba@2247: check((ListGraph::Node)it == n5, "Wrong Path"); ++it; deba@2247: check((ListGraph::Node)it == INVALID, "Wrong Path"); deba@2247: } deba@2247: deba@2247: { deba@2247: Path::EdgeIt it(p); deba@2247: check((ListGraph::Edge)it == e2, "Wrong Path"); ++it; deba@2247: check((ListGraph::Edge)it == e3, "Wrong Path"); ++it; deba@2247: check((ListGraph::Edge)it == e4, "Wrong Path"); ++it; deba@2247: check((ListGraph::Edge)it == INVALID, "Wrong Path"); deba@2247: } deba@2247: deba@2247: } deba@2247: deba@2247: return 0; hegyi@820: }