COIN-OR::LEMON - Graph Library

Ticket #447: lookupTest.cpp

File lookupTest.cpp, 913 bytes (added by Alpar Juttner, 12 years ago)
Line 
1#include "lemon/list_graph.h"
2#include "lemon/lgf_reader.h"
3
4#include <iostream>
5
6using namespace lemon;
7
8int main() {
9  ListDigraph graph;
10  ListDigraph::NodeMap<int> nlabel(graph);
11  DigraphReader<ListDigraph>(graph, "lookupTest.lgf")
12    .nodeMap("label",nlabel)
13    .run();
14       
15  AllArcLookUp<ListDigraph> lookup(graph);
16       
17  int numArcs = countArcs(graph);
18       
19  int arcCnt = 0;
20  for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1) {
21    int cnt = 0;
22    for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2) {
23      int cnt2 = 0;
24      for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID;
25          a = lookup(n1, n2, a)) {
26        ++arcCnt;
27        ++ cnt;
28        ++ cnt2;
29      }
30      std::cout << "    " << nlabel[n1] << "->" << nlabel[n2] << ": " << cnt2
31                << std::endl;
32    }
33    std::cout << "  " << nlabel[n1] << ": " << cnt
34              << std::endl;
35  }
36       
37  std::cout << numArcs << "," << arcCnt << std::endl;
38       
39  return 0;
40}