COIN-OR::LEMON - Graph Library

Ticket #47: suurb1_39ff10276621.patch

File suurb1_39ff10276621.patch, 5.4 KB (added by Peter Kovacs, 15 years ago)
  • lemon/suurballe.h

    # HG changeset patch
    # User Peter Kovacs <kpeter@inf.elte.hu>
    # Date 1225228851 -3600
    # Node ID 39ff10276621ccdf7d74451efba324da4253b626
    # Parent  2f64c4a692a87056623c6fffafd76432806ee593
    Apply the unifier script to the Suurballe related files
    
    diff --git a/lemon/suurballe.h b/lemon/suurballe.h
    a b  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    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 *
    55 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     
    5353  /// with \ref SplitDigraphAdaptor.
    5454  ///
    5555  /// \author Attila Bernath and Peter Kovacs
    56  
    57   template < typename Digraph, 
     56
     57  template < typename Digraph,
    5858             typename LengthMap = typename Digraph::template ArcMap<int> >
    5959  class Suurballe
    6060  {
     
    7474    typedef SimplePath<Digraph> Path;
    7575
    7676  private:
    77  
     77
    7878    /// \brief Special implementation of the \ref Dijkstra algorithm
    7979    /// for finding shortest paths in the residual network.
    8080    ///
     
    104104      PredMap &_pred;
    105105      // The processed (i.e. permanently labeled) nodes
    106106      std::vector<Node> _proc_nodes;
    107      
     107
    108108      Node _s;
    109109      Node _t;
    110110
     
    198198    const Digraph &_graph;
    199199    // The length map
    200200    const LengthMap &_length;
    201    
     201
    202202    // Arc map of the current flow
    203203    FlowMap *_flow;
    204204    bool _local_flow;
     
    266266    ///
    267267    /// Sets the potential map.
    268268    ///
    269     /// The potentials provide the dual solution of the underlying 
     269    /// The potentials provide the dual solution of the underlying
    270270    /// minimum cost flow problem.
    271271    ///
    272272    /// \return \c (*this)
     
    328328      for (ArcIt e(_graph); e != INVALID; ++e) (*_flow)[e] = 0;
    329329      for (NodeIt n(_graph); n != INVALID; ++n) (*_potential)[n] = 0;
    330330
    331       _dijkstra = new ResidualDijkstra( _graph, *_flow, _length, 
     331      _dijkstra = new ResidualDijkstra( _graph, *_flow, _length,
    332332                                        *_potential, _pred,
    333333                                        _source, _target );
    334334    }
     
    368368      }
    369369      return _path_num;
    370370    }
    371    
     371
    372372    /// \brief Computes the paths from the flow.
    373373    ///
    374374    /// Computes the paths from the flow.
     
    420420    /// found potentials (the dual solution).
    421421    ///
    422422    /// Returns a const reference to the node map storing the found
    423     /// potentials that provide the dual solution of the underlying 
     423    /// potentials that provide the dual solution of the underlying
    424424    /// minimum cost flow problem.
    425425    ///
    426426    /// \pre \ref run() or findFlow() must be called before using this
  • test/suurballe_test.cc

    diff --git a/test/suurballe_test.cc b/test/suurballe_test.cc
    a b  
    1 /* -*- C++ -*-
     1/* -*- mode: C++; indent-tabs-mode: nil; -*-
    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 *
    55 * Copyright (C) 2003-2008
    66 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     
    3030
    3131// Checks the feasibility of the flow
    3232template <typename Digraph, typename FlowMap>
    33 bool checkFlow( const Digraph& gr, const FlowMap& flow, 
     33bool checkFlow( const Digraph& gr, const FlowMap& flow,
    3434                typename Digraph::Node s, typename Digraph::Node t,
    3535                int value )
    3636{
     
    5353}
    5454
    5555// Checks the optimalitiy of the flow
    56 template < typename Digraph, typename CostMap, 
     56template < typename Digraph, typename CostMap,
    5757           typename FlowMap, typename PotentialMap >
    5858bool checkOptimality( const Digraph& gr, const CostMap& cost,
    5959                      const FlowMap& flow, const PotentialMap& pi )
     
    110110    node("target", target).
    111111    run();
    112112  input.close();
    113  
     113
    114114  // Finding 2 paths
    115115  {
    116116    Suurballe<ListDigraph> suurballe(digraph, length, source, target);
     
    118118    check(checkFlow(digraph, suurballe.flowMap(), source, target, 2),
    119119          "The flow is not feasible");
    120120    check(suurballe.totalLength() == 510, "The flow is not optimal");
    121     check(checkOptimality(digraph, length, suurballe.flowMap(), 
     121    check(checkOptimality(digraph, length, suurballe.flowMap(),
    122122                          suurballe.potentialMap()),
    123123          "Wrong potentials");
    124124    for (int i = 0; i < suurballe.pathNum(); ++i)
     
    133133    check(checkFlow(digraph, suurballe.flowMap(), source, target, 3),
    134134          "The flow is not feasible");
    135135    check(suurballe.totalLength() == 1040, "The flow is not optimal");
    136     check(checkOptimality(digraph, length, suurballe.flowMap(), 
     136    check(checkOptimality(digraph, length, suurballe.flowMap(),
    137137                          suurballe.potentialMap()),
    138138          "Wrong potentials");
    139139    for (int i = 0; i < suurballe.pathNum(); ++i)
     
    148148    check(checkFlow(digraph, suurballe.flowMap(), source, target, 3),
    149149          "The flow is not feasible");
    150150    check(suurballe.totalLength() == 1040, "The flow is not optimal");
    151     check(checkOptimality(digraph, length, suurballe.flowMap(), 
     151    check(checkOptimality(digraph, length, suurballe.flowMap(),
    152152                          suurballe.potentialMap()),
    153153          "Wrong potentials");
    154154    for (int i = 0; i < suurballe.pathNum(); ++i)