1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test/arc_look_up_test.cc Fri Aug 24 15:50:54 2012 +0200
1.3 @@ -0,0 +1,85 @@
1.4 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
1.5 + *
1.6 + * This file is a part of LEMON, a generic C++ optimization library.
1.7 + *
1.8 + * Copyright (C) 2003-2009
1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 + *
1.12 + * Permission to use, modify and distribute this software is granted
1.13 + * provided that this copyright notice appears in all copies. For
1.14 + * precise terms see the accompanying LICENSE file.
1.15 + *
1.16 + * This software is provided "AS IS" with no warranty of any kind,
1.17 + * express or implied, and with no claim as to its suitability for any
1.18 + * purpose.
1.19 + *
1.20 + */
1.21 +
1.22 +#include <iostream>
1.23 +#include "lemon/list_graph.h"
1.24 +#include "lemon/lgf_reader.h"
1.25 +
1.26 +#include "test_tools.h"
1.27 +
1.28 +using namespace lemon;
1.29 +
1.30 +const int lgfn = 4;
1.31 +const std::string lgf =
1.32 + "@nodes\n"
1.33 +"label\n"
1.34 +"0\n"
1.35 +"1\n"
1.36 +"2\n"
1.37 +"3\n"
1.38 +"4\n"
1.39 +"5\n"
1.40 +"6\n"
1.41 +"@arcs\n"
1.42 +"label\n"
1.43 +"5 6 0\n"
1.44 +"5 4 1\n"
1.45 +"4 6 2\n"
1.46 +"3 4 3\n"
1.47 +"3 4 4\n"
1.48 +"3 2 5\n"
1.49 +"3 5 6\n"
1.50 +"3 5 7\n"
1.51 +"3 5 8\n"
1.52 +"3 5 9\n"
1.53 +"2 4 10\n"
1.54 +"2 4 11\n"
1.55 +"2 4 12\n"
1.56 +"2 4 13\n"
1.57 +"1 2 14\n"
1.58 +"1 2 15\n"
1.59 +"1 0 16\n"
1.60 +"1 3 17\n"
1.61 +"1 3 18\n"
1.62 +"1 3 19\n"
1.63 +"1 3 20\n"
1.64 +"0 2 21\n"
1.65 +"0 2 22\n"
1.66 +"0 2 23\n"
1.67 +"0 2 24\n";
1.68 +
1.69 +
1.70 +int main() {
1.71 + ListDigraph graph;
1.72 + std::istringstream lgfs(lgf);
1.73 + DigraphReader<ListDigraph>(graph, lgfs).run();
1.74 +
1.75 + AllArcLookUp<ListDigraph> lookup(graph);
1.76 +
1.77 + int numArcs = countArcs(graph);
1.78 +
1.79 + int arcCnt = 0;
1.80 + for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1)
1.81 + for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2)
1.82 + for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID;
1.83 + a = lookup(n1, n2, a))
1.84 + ++arcCnt;
1.85 + check(arcCnt==numArcs, "Wrong total number of arcs");
1.86 +
1.87 + return 0;
1.88 +}