test/arc_look_up_test.cc
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 15 May 2015 10:16:48 +0200
changeset 1354 1de908281369
parent 1270 dceba191c00d
permissions -rw-r--r--
Update Doxyfile.in

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