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