src/work/deba/main.cpp
author alpar
Fri, 23 Jul 2004 17:13:23 +0000
changeset 737 2d867176d10e
parent 702 4207f82a1778
child 922 e816fac59f6d
permissions -rw-r--r--
Several changes in Kruskal alg.
- Input object interface was changed to an STL compatible one.
- template parameters of class KruskalPairVec has been simplified.
- (the most of) the names meet the naming conventions.
- a lot of (but still not enough) documentation has been added.
- class KruskalMapVec has been commented out.
     1 // -*- c++ -*-
     2 #include <iostream>
     3 #include <cstdlib>
     4 #include "list_graph.h"
     5 
     6 using namespace std;
     7 using namespace hugo;
     8 
     9 
    10 
    11 int main() {
    12   ListGraph g;
    13   for (int i = 0; i < 10; ++i) {
    14     ListGraph::Node node = g.addNode();
    15   }
    16   ListGraph::NodeMap<int> map(g, 10);
    17   for (int i = 0; i < 10; ++i) {
    18     ListGraph::Node node = g.addNode();
    19     map[node] = rand()%100;
    20   }
    21   for (ListGraph::NodeIt it(g); g.valid(it); g.next(it)) {
    22     cout << map[it] << endl;
    23   }
    24   ListGraph::NodeMap<int>::iterator pit;
    25   for (pit = map.begin(); pit != map.end(); ++pit) {
    26     cout << g.id(pit->first) << ' ' << pit->second << endl;
    27     (*pit).second = g.id(pit->first);
    28     cout << g.id((*pit).first) << ' ' << (*pit).second << endl;
    29   }  
    30   const ListGraph::NodeMap<int> const_map = map;
    31   ListGraph::NodeMap<int>::const_iterator cit;
    32   for (cit = const_map.begin(); cit != const_map.end(); ++cit) {
    33     cerr << g.id(cit->first) << ' ' << cit->second << endl;
    34     cerr << g.id((*cit).first) << ' ' << (*cit).second << endl;
    35   }  
    36   return 0;
    37 }
    38