test/ugraph_test.cc
changeset 2071 00c4ce4f4170
parent 1956 a055123339d5
child 2111 ea1fa1bc3f6d
equal deleted inserted replaced
1:be9f92edbb13 2:27df90e6bd19
    19 #include <lemon/bits/graph_extender.h>
    19 #include <lemon/bits/graph_extender.h>
    20 #include <lemon/concept/ugraph.h>
    20 #include <lemon/concept/ugraph.h>
    21 #include <lemon/list_graph.h>
    21 #include <lemon/list_graph.h>
    22 #include <lemon/smart_graph.h>
    22 #include <lemon/smart_graph.h>
    23 #include <lemon/full_graph.h>
    23 #include <lemon/full_graph.h>
    24 #include <lemon/grid_graph.h>
    24 #include <lemon/grid_ugraph.h>
    25 
    25 
    26 #include <lemon/graph_utils.h>
    26 #include <lemon/graph_utils.h>
    27 
    27 
    28 #include "test_tools.h"
    28 #include "test_tools.h"
    29 
    29 
    30 
    30 
    31 using namespace lemon;
    31 using namespace lemon;
    32 using namespace lemon::concept;
    32 using namespace lemon::concept;
    33 
    33 
    34 void check_concepts() {
    34 void check_concepts() {
    35   typedef UGraphExtender<ListGraphBase> ListUGraphBase;
       
    36 
       
    37   typedef IterableUGraphExtender<
       
    38     AlterableUGraphExtender<ListUGraphBase> > IterableListUGraph;
       
    39 
       
    40   typedef MappableUGraphExtender<IterableListUGraph>
       
    41     MappableListUGraph;
       
    42 
       
    43   typedef ErasableUGraphExtender<
       
    44     ClearableUGraphExtender<
       
    45     ExtendableUGraphExtender<MappableListUGraph> > > Graph;
       
    46 
       
    47   checkConcept<BaseIterableUGraphConcept, Graph>();
       
    48   checkConcept<IterableUGraphConcept, Graph>();
       
    49   checkConcept<MappableUGraphConcept, Graph>();
       
    50 
       
    51   checkConcept<UGraph, Graph>();
       
    52   checkConcept<ErasableUGraph, Graph>();
       
    53 
       
    54   checkConcept<UGraph, ListUGraph>();
    35   checkConcept<UGraph, ListUGraph>();
    55   checkConcept<ErasableUGraph, ListUGraph>();
    36   checkConcept<ErasableUGraph, ListUGraph>();
    56 
    37 
    57   checkConcept<UGraph, SmartUGraph>();
    38   checkConcept<UGraph, SmartUGraph>();
    58   checkConcept<ExtendableUGraph, SmartUGraph>();
    39   checkConcept<ExtendableUGraph, SmartUGraph>();
    59 
    40 
    60   checkConcept<UGraph, FullUGraph>();
    41   checkConcept<UGraph, FullUGraph>();
    61 
    42 
    62   checkConcept<UGraph, UGraph>();
    43   checkConcept<UGraph, UGraph>();
    63 
    44 
    64   checkConcept<UGraph, GridGraph>();
    45   checkConcept<UGraph, GridUGraph>();
    65 }
    46 }
    66 
    47 
    67 template <typename Graph>
    48 template <typename Graph>
    68 void check_item_counts(Graph &g, int n, int e) {
    49 void check_item_counts(Graph &g, int n, int e) {
    69   int nn = 0;
    50   int nn = 0;
   148   // print_items(g);
   129   // print_items(g);
   149 
   130 
   150   check_item_counts(g,3,2);
   131   check_item_counts(g,3,2);
   151 }
   132 }
   152 
   133 
   153 void checkGridGraph(const GridGraph& g, int w, int h) {
   134 void checkGridUGraph(const GridUGraph& g, int w, int h) {
   154   check(g.width() == w, "Wrong width");
   135   check(g.width() == w, "Wrong width");
   155   check(g.height() == h, "Wrong height");
   136   check(g.height() == h, "Wrong height");
   156 
   137 
   157   for (int i = 0; i < w; ++i) {
   138   for (int i = 0; i < w; ++i) {
   158     for (int j = 0; j < h; ++j) {
   139     for (int j = 0; j < h; ++j) {
   204     FullUGraph g(5);
   185     FullUGraph g(5);
   205     check_item_counts(g, 5, 10);
   186     check_item_counts(g, 5, 10);
   206   }
   187   }
   207 
   188 
   208   {
   189   {
   209     GridGraph g(5, 6);
   190     GridUGraph g(5, 6);
   210     check_item_counts(g, 30, 49);
   191     check_item_counts(g, 30, 49);
   211     checkGridGraph(g, 5, 6);
   192     checkGridUGraph(g, 5, 6);
   212   }
   193   }
   213 
   194 
   214   std::cout << __FILE__ ": All tests passed.\n";
   195   std::cout << __FILE__ ": All tests passed.\n";
   215 
   196 
   216   return 0;
   197   return 0;