test/arc_look_up_test.cc
branch1.2
changeset 972 1fe3b4ad8caa
equal deleted inserted replaced
-1:000000000000 0:c9430fa587f2
       
     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-2009
       
     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 int lgfn = 4;
       
    28 const std::string lgf =
       
    29   "@nodes\n"
       
    30 "label\n"
       
    31 "0\n"
       
    32 "1\n"
       
    33 "2\n"
       
    34 "3\n"
       
    35 "4\n"
       
    36 "5\n"
       
    37 "6\n"
       
    38 "@arcs\n"
       
    39 "label\n"
       
    40 "5 6 0\n"
       
    41 "5 4 1\n"
       
    42 "4 6 2\n"
       
    43 "3 4 3\n"
       
    44 "3 4 4\n"
       
    45 "3 2 5\n"
       
    46 "3 5 6\n"
       
    47 "3 5 7\n"
       
    48 "3 5 8\n"
       
    49 "3 5 9\n"
       
    50 "2 4 10\n"
       
    51 "2 4 11\n"
       
    52 "2 4 12\n"
       
    53 "2 4 13\n"
       
    54 "1 2 14\n"
       
    55 "1 2 15\n"
       
    56 "1 0 16\n"
       
    57 "1 3 17\n"
       
    58 "1 3 18\n"
       
    59 "1 3 19\n"
       
    60 "1 3 20\n"
       
    61 "0 2 21\n"
       
    62 "0 2 22\n"
       
    63 "0 2 23\n"
       
    64 "0 2 24\n";
       
    65 
       
    66 
       
    67 int main() {
       
    68   ListDigraph graph;
       
    69   std::istringstream lgfs(lgf);
       
    70   DigraphReader<ListDigraph>(graph, lgfs).run();
       
    71   
       
    72   AllArcLookUp<ListDigraph> lookup(graph);
       
    73 	
       
    74   int numArcs = countArcs(graph);
       
    75 	
       
    76   int arcCnt = 0;
       
    77   for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1)
       
    78     for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2)
       
    79       for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID;
       
    80 	  a = lookup(n1, n2, a))
       
    81 	++arcCnt;
       
    82   check(arcCnt==numArcs, "Wrong total number of arcs");
       
    83 
       
    84   return 0;
       
    85 }