test/path_test.cc
author deba
Mon, 27 Feb 2006 10:36:01 +0000
changeset 1986 9b56cca61e2e
parent 1909 2d806130e700
child 2247 269a0dcee70b
permissions -rw-r--r--
An additional simplier interface for static size graphs.
Node operator()(int) for getting node by index
int index(Node node) for getting index by node
     1 /* -*- C++ -*-
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library
     4  *
     5  * Copyright (C) 2003-2006
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    11  * precise terms see the accompanying LICENSE file.
    12  *
    13  * This software is provided "AS IS" with no warranty of any kind,
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    16  *
    17  */
    18 
    19 #include <string>
    20 #include <iostream>
    21 #include <lemon/concept/path.h>
    22 #include <lemon/path.h>
    23 #include <lemon/list_graph.h>
    24 
    25 using namespace std;
    26 using namespace lemon;
    27 using namespace lemon::concept;
    28 
    29 template<class Path> void checkCompilePath(Path &P) 
    30 {
    31   typedef typename Path::EdgeIt EdgeIt;
    32   typedef typename Path::NodeIt NodeIt;
    33   typedef typename Path::GraphNode GraphNode;
    34   typedef typename Path::GraphEdge GraphEdge;
    35   //typedef typename Path::Builder Builder;
    36   //??? ha csinalok ilyet es siman Builderrel peldanyositok, akkor warningol. Talan friend miatt? De ki az?
    37 
    38   EdgeIt ei;
    39   NodeIt ni;
    40   GraphNode gn;
    41   GraphEdge ge;
    42 
    43   size_t st;
    44   bool b;
    45 
    46   //Path(const Graph &_G) {}      //the constructor has been already called
    47 
    48   st=P.length();                  //size_t length() const {return 0;}
    49   b=P.empty();                    //bool empty() const {}
    50   P.clear();                      //void clear() {}
    51 
    52   gn=P.target();                    //GraphNode/*It*/ target() const {return INVALID;}
    53   gn=P.source();                    //GraphNode/*It*/ source() const {return INVALID;}
    54 
    55   ei=P.first(ei);                 //It& first(It &i) const { return i=It(*this); }
    56 
    57   ni=P.target(ei);                  //NodeIt target(const EdgeIt& e) const {}
    58   ni=P.source(ei);                  //NodeIt source(const EdgeIt& e) const {}
    59 
    60 
    61   ListGraph lg;
    62   Path p(lg);
    63 
    64   EdgeIt i;	                  //EdgeIt() {}
    65   EdgeIt j(INVALID);	          //EdgeIt(Invalid) {}
    66   EdgeIt k(p);	                  //EdgeIt(const Path &_p) {}
    67 
    68   i=++j;	                  //EdgeIt& operator++() {}
    69   ++k;
    70   b=(i==j);	                  //bool operator==(const EdgeIt& e) const {return true;}
    71   b=(i!=j);	                  //bool operator!=(const EdgeIt& e) const {return true;}
    72 
    73 
    74   NodeIt l;                       //NodeIt() {}
    75   NodeIt m(INVALID);	          //NodeIt(Invalid) {}
    76   NodeIt n(p);	                  //NodeIt(const Path &_p) {}
    77 
    78   l=++m;                          //NodeIt& operator++() {}
    79   b=(m==n);                       //bool operator==(const NodeIt& e) const {}
    80   b=(m!=n);                   	  //bool operator!=(const NodeIt& e) const {}
    81 
    82   typename Path::Builder builder(p);     //Builder(Path &_P) : P(_P) {}
    83   builder.setStartNode(gn);     	 //void setStartNode(const GraphNode &) {}
    84   builder.pushFront(ge);	         //void pushFront(const GraphEdge& e) {}
    85   builder.pushBack(ge);	                 //void pushBack(const GraphEdge& e) {}
    86   builder.commit();	                 //void commit() {}
    87   builder.reserveFront(st);	         //void reserveFront(size_t r) {}
    88   builder.reserveBack(st);	         //void reserveBack(size_t r) {}
    89 
    90 }
    91 
    92 template void checkCompilePath< concept::Path<ListGraph> >(concept::Path<ListGraph> &);
    93 template void checkCompilePath< DirPath<ListGraph> >(DirPath<ListGraph> &);
    94 template void checkCompilePath< UPath<ListGraph> >(UPath<ListGraph> &);
    95 
    96 int main() 
    97 {
    98 }