src/work/deba/main.cpp
author alpar
Sat, 13 Nov 2004 12:53:28 +0000
changeset 986 e997802b855c
parent 703 32f280a5ed7d
permissions -rw-r--r--
Naming changes:
- head -> target
- tail -> source
deba@703
     1
// -*- c++ -*-
deba@378
     2
#include <iostream>
deba@595
     3
#include <cstdlib>
deba@698
     4
#include "list_graph.h"
deba@378
     5
deba@378
     6
using namespace std;
klao@922
     7
using namespace lemon;
deba@378
     8
deba@378
     9
deba@703
    10
deba@378
    11
int main() {
deba@627
    12
  ListGraph g;
deba@627
    13
  for (int i = 0; i < 10; ++i) {
deba@627
    14
    ListGraph::Node node = g.addNode();
deba@627
    15
  }
deba@701
    16
  ListGraph::NodeMap<int> map(g, 10);
deba@627
    17
  for (int i = 0; i < 10; ++i) {
deba@627
    18
    ListGraph::Node node = g.addNode();
deba@627
    19
    map[node] = rand()%100;
deba@627
    20
  }
deba@627
    21
  for (ListGraph::NodeIt it(g); g.valid(it); g.next(it)) {
deba@627
    22
    cout << map[it] << endl;
deba@627
    23
  }
deba@701
    24
  ListGraph::NodeMap<int>::iterator pit;
deba@701
    25
  for (pit = map.begin(); pit != map.end(); ++pit) {
deba@701
    26
    cout << g.id(pit->first) << ' ' << pit->second << endl;
deba@703
    27
    (*pit).second = g.id(pit->first);
deba@703
    28
    cout << g.id((*pit).first) << ' ' << (*pit).second << endl;
deba@703
    29
  }  
deba@703
    30
  const ListGraph::NodeMap<int> const_map = map;
deba@703
    31
  ListGraph::NodeMap<int>::const_iterator cit;
deba@703
    32
  for (cit = const_map.begin(); cit != const_map.end(); ++cit) {
deba@703
    33
    cerr << g.id(cit->first) << ' ' << cit->second << endl;
deba@703
    34
    cerr << g.id((*cit).first) << ' ' << (*cit).second << endl;
deba@703
    35
  }  
deba@627
    36
  return 0;
deba@378
    37
}
deba@378
    38