COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/suurballe_test.cc

    r440 r346  
    1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1/* -*- C++ -*-
    22 *
    3  * This file is a part of LEMON, a generic C++ optimization library.
     3 * This file is a part of LEMON, a generic C++ optimization library
    44 *
    5  * Copyright (C) 2003-2009
     5 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    77 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     
    1818
    1919#include <iostream>
     20#include <fstream>
    2021
    2122#include <lemon/list_graph.h>
     
    2829using namespace lemon;
    2930
    30 char test_lgf[] =
    31   "@nodes\n"
    32   "label supply1 supply2 supply3\n"
    33   "1     0        20      27\n"
    34   "2     0       -4        0\n"
    35   "3     0        0        0\n"
    36   "4     0        0        0\n"
    37   "5     0        9        0\n"
    38   "6     0       -6        0\n"
    39   "7     0        0        0\n"
    40   "8     0        0        0\n"
    41   "9     0        3        0\n"
    42   "10    0       -2        0\n"
    43   "11    0        0        0\n"
    44   "12    0       -20     -27\n"
    45   "@arcs\n"
    46   "      cost capacity lower1 lower2\n"
    47   " 1  2  70  11       0      8\n"
    48   " 1  3 150   3       0      1\n"
    49   " 1  4  80  15       0      2\n"
    50   " 2  8  80  12       0      0\n"
    51   " 3  5 140   5       0      3\n"
    52   " 4  6  60  10       0      1\n"
    53   " 4  7  80   2       0      0\n"
    54   " 4  8 110   3       0      0\n"
    55   " 5  7  60  14       0      0\n"
    56   " 5 11 120  12       0      0\n"
    57   " 6  3   0   3       0      0\n"
    58   " 6  9 140   4       0      0\n"
    59   " 6 10  90   8       0      0\n"
    60   " 7  1  30   5       0      0\n"
    61   " 8 12  60  16       0      4\n"
    62   " 9 12  50   6       0      0\n"
    63   "10 12  70  13       0      5\n"
    64   "10  2 100   7       0      0\n"
    65   "10  7  60  10       0      0\n"
    66   "11 10  20  14       0      6\n"
    67   "12 11  30  10       0      0\n"
    68   "@attributes\n"
    69   "source  1\n"
    70   "target 12\n"
    71   "@end\n";
    72 
    7331// Check the feasibility of the flow
    7432template <typename Digraph, typename FlowMap>
    75 bool checkFlow( const Digraph& gr, const FlowMap& flow,
     33bool checkFlow( const Digraph& gr, const FlowMap& flow, 
    7634                typename Digraph::Node s, typename Digraph::Node t,
    7735                int value )
     
    9654
    9755// Check the optimalitiy of the flow
    98 template < typename Digraph, typename CostMap,
     56template < typename Digraph, typename CostMap, 
    9957           typename FlowMap, typename PotentialMap >
    10058bool checkOptimality( const Digraph& gr, const CostMap& cost,
     
    13997  Node source, target;
    14098
    141   std::istringstream input(test_lgf);
     99  std::string fname;
     100  if(getenv("srcdir"))
     101    fname = std::string(getenv("srcdir"));
     102  else fname = ".";
     103  fname += "/test/min_cost_flow_test.lgf";
     104
     105  std::ifstream input(fname.c_str());
     106  check(input, "Input file '" << fname << "' not found");
    142107  DigraphReader<ListDigraph>(digraph, input).
    143108    arcMap("cost", length).
     
    145110    node("target", target).
    146111    run();
    147 
     112  input.close();
     113 
    148114  // Find 2 paths
    149115  {
     
    153119          "The flow is not feasible");
    154120    check(suurballe.totalLength() == 510, "The flow is not optimal");
    155     check(checkOptimality(digraph, length, suurballe.flowMap(),
     121    check(checkOptimality(digraph, length, suurballe.flowMap(), 
    156122                          suurballe.potentialMap()),
    157123          "Wrong potentials");
     
    168134          "The flow is not feasible");
    169135    check(suurballe.totalLength() == 1040, "The flow is not optimal");
    170     check(checkOptimality(digraph, length, suurballe.flowMap(),
     136    check(checkOptimality(digraph, length, suurballe.flowMap(), 
    171137                          suurballe.potentialMap()),
    172138          "Wrong potentials");
     
    183149          "The flow is not feasible");
    184150    check(suurballe.totalLength() == 1040, "The flow is not optimal");
    185     check(checkOptimality(digraph, length, suurballe.flowMap(),
     151    check(checkOptimality(digraph, length, suurballe.flowMap(), 
    186152                          suurballe.potentialMap()),
    187153          "Wrong potentials");
Note: See TracChangeset for help on using the changeset viewer.