src/work/marci/merge_node_graph_wrapper_test.cc
author marci
Sat, 16 Oct 2004 00:20:13 +0000
changeset 944 4f064aff855e
parent 917 ffb8f0cbcb57
child 1007 a7d5fe18d8f9
permissions -rw-r--r--
It's time to design an iterable generic bfs
     1 #include <iostream>
     2 
     3 #include <lemon/list_graph.h>
     4 #include <lemon/smart_graph.h>
     5 #include <merge_node_graph_wrapper.h>
     6 
     7 using std::cout;
     8 using std::endl;
     9 
    10 using namespace lemon;
    11 
    12 int main() {
    13   typedef SmartGraph Graph1;
    14   typedef ListGraph Graph2;
    15   Graph1 g;
    16   Graph2 h;
    17   typedef MergeNodeGraphWrapper<Graph1, Graph2> GW;
    18   GW gw(g, h);
    19   Graph1::Node n1=g.addNode();
    20   Graph1::Node n2=g.addNode();
    21   Graph1::Node n3=g.addNode();
    22   Graph2::Node n4=h.addNode();
    23   Graph2::Node n5=h.addNode();
    24   //GW::NodeIt n(gw)
    25   for (GW::NodeIt n(gw); n!=INVALID; ++n) { 
    26     cout << gw.id(n) << endl;
    27   }
    28 
    29   GW::NodeMap<int> nm(gw);
    30   int i=0;
    31   for (GW::NodeIt n(gw); n!=INVALID; ++n) { 
    32     ++i;
    33     nm.set(n, i);
    34   }
    35   for (Graph1::NodeIt n(g); n!=INVALID; ++n) { 
    36     cout << nm[n] << endl;
    37   }
    38   for (Graph2::NodeIt n(h); n!=INVALID; ++n) { 
    39     cout << nm[n] << endl;
    40   }
    41 }