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