test/arc_look_up_test.cc
author Alpar Juttner <alpar@cs.elte.hu>
Wed, 12 Sep 2012 17:34:01 +0200
changeset 996 b6347aae6575
child 1092 dceba191c00d
permissions -rw-r--r--
Merge bugfix #448
alpar@993
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
alpar@993
     2
 *
alpar@993
     3
 * This file is a part of LEMON, a generic C++ optimization library.
alpar@993
     4
 *
alpar@993
     5
 * Copyright (C) 2003-2009
alpar@993
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@993
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@993
     8
 *
alpar@993
     9
 * Permission to use, modify and distribute this software is granted
alpar@993
    10
 * provided that this copyright notice appears in all copies. For
alpar@993
    11
 * precise terms see the accompanying LICENSE file.
alpar@993
    12
 *
alpar@993
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@993
    14
 * express or implied, and with no claim as to its suitability for any
alpar@993
    15
 * purpose.
alpar@993
    16
 *
alpar@993
    17
 */
alpar@993
    18
alpar@993
    19
#include <iostream>
alpar@993
    20
#include "lemon/list_graph.h"
alpar@993
    21
#include "lemon/lgf_reader.h"
alpar@993
    22
alpar@993
    23
#include "test_tools.h"
alpar@993
    24
alpar@993
    25
using namespace lemon;
alpar@993
    26
alpar@993
    27
const int lgfn = 4;
alpar@993
    28
const std::string lgf =
alpar@993
    29
  "@nodes\n"
alpar@993
    30
"label\n"
alpar@993
    31
"0\n"
alpar@993
    32
"1\n"
alpar@993
    33
"2\n"
alpar@993
    34
"3\n"
alpar@993
    35
"4\n"
alpar@993
    36
"5\n"
alpar@993
    37
"6\n"
alpar@993
    38
"@arcs\n"
alpar@993
    39
"label\n"
alpar@993
    40
"5 6 0\n"
alpar@993
    41
"5 4 1\n"
alpar@993
    42
"4 6 2\n"
alpar@993
    43
"3 4 3\n"
alpar@993
    44
"3 4 4\n"
alpar@993
    45
"3 2 5\n"
alpar@993
    46
"3 5 6\n"
alpar@993
    47
"3 5 7\n"
alpar@993
    48
"3 5 8\n"
alpar@993
    49
"3 5 9\n"
alpar@993
    50
"2 4 10\n"
alpar@993
    51
"2 4 11\n"
alpar@993
    52
"2 4 12\n"
alpar@993
    53
"2 4 13\n"
alpar@993
    54
"1 2 14\n"
alpar@993
    55
"1 2 15\n"
alpar@993
    56
"1 0 16\n"
alpar@993
    57
"1 3 17\n"
alpar@993
    58
"1 3 18\n"
alpar@993
    59
"1 3 19\n"
alpar@993
    60
"1 3 20\n"
alpar@993
    61
"0 2 21\n"
alpar@993
    62
"0 2 22\n"
alpar@993
    63
"0 2 23\n"
alpar@993
    64
"0 2 24\n";
alpar@993
    65
alpar@993
    66
alpar@993
    67
int main() {
alpar@993
    68
  ListDigraph graph;
alpar@993
    69
  std::istringstream lgfs(lgf);
alpar@993
    70
  DigraphReader<ListDigraph>(graph, lgfs).run();
alpar@993
    71
  
alpar@993
    72
  AllArcLookUp<ListDigraph> lookup(graph);
alpar@993
    73
	
alpar@993
    74
  int numArcs = countArcs(graph);
alpar@993
    75
	
alpar@993
    76
  int arcCnt = 0;
alpar@993
    77
  for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1)
alpar@993
    78
    for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2)
alpar@993
    79
      for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID;
alpar@993
    80
	  a = lookup(n1, n2, a))
alpar@993
    81
	++arcCnt;
alpar@993
    82
  check(arcCnt==numArcs, "Wrong total number of arcs");
alpar@993
    83
alpar@993
    84
  return 0;
alpar@993
    85
}