lemon/min_cost_flow.h
author deba
Tue, 04 Dec 2007 14:08:27 +0000
changeset 2531 426a4e35e167
parent 2474 e6368948d5f7
child 2533 aea952a1af99
permissions -rw-r--r--
rename graphs script
deba@2440
     1
/* -*- C++ -*-
deba@2440
     2
 *
deba@2440
     3
 * This file is a part of LEMON, a generic C++ optimization library
deba@2440
     4
 *
deba@2440
     5
 * Copyright (C) 2003-2007
deba@2440
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@2440
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@2440
     8
 *
deba@2440
     9
 * Permission to use, modify and distribute this software is granted
deba@2440
    10
 * provided that this copyright notice appears in all copies. For
deba@2440
    11
 * precise terms see the accompanying LICENSE file.
deba@2440
    12
 *
deba@2440
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@2440
    14
 * express or implied, and with no claim as to its suitability for any
deba@2440
    15
 * purpose.
deba@2440
    16
 *
deba@2440
    17
 */
deba@2440
    18
deba@2440
    19
#ifndef LEMON_MIN_COST_FLOW_H
deba@2440
    20
#define LEMON_MIN_COST_FLOW_H
deba@2440
    21
deba@2440
    22
/// \ingroup min_cost_flow
deba@2440
    23
///
deba@2440
    24
/// \file
deba@2440
    25
/// \brief An efficient algorithm for finding a minimum cost flow.
deba@2440
    26
deba@2440
    27
#include <lemon/network_simplex.h>
deba@2440
    28
deba@2440
    29
namespace lemon {
deba@2440
    30
deba@2440
    31
  /// \addtogroup min_cost_flow
deba@2440
    32
  /// @{
deba@2440
    33
deba@2440
    34
  /// \brief An efficient algorithm for finding a minimum cost flow.
deba@2440
    35
  ///
deba@2440
    36
  /// \ref lemon::MinCostFlow "MinCostFlow" implements an efficient
deba@2440
    37
  /// algorithm for finding a minimum cost flow.
deba@2440
    38
  ///
deba@2440
    39
  /// \note \ref lemon::MinCostFlow "MinCostFlow" is just an alias for
deba@2440
    40
  /// \ref lemon::NetworkSimplex "NetworkSimplex", wich is the most
deba@2440
    41
  /// efficient implementation for the minimum cost flow problem in the
kpeter@2474
    42
  /// LEMON library according to our benchmark tests.
deba@2440
    43
  ///
deba@2440
    44
  /// \note There are three implementations for the minimum cost flow
deba@2440
    45
  /// problem, that can be used in the same way.
deba@2440
    46
  /// - \ref lemon::CapacityScaling "CapacityScaling"
deba@2440
    47
  /// - \ref lemon::CycleCanceling "CycleCanceling"
deba@2440
    48
  /// - \ref lemon::NetworkSimplex "NetworkSimplex"
deba@2440
    49
  ///
deba@2440
    50
  /// \param Graph The directed graph type the algorithm runs on.
deba@2440
    51
  /// \param LowerMap The type of the lower bound map.
deba@2440
    52
  /// \param CapacityMap The type of the capacity (upper bound) map.
deba@2440
    53
  /// \param CostMap The type of the cost (length) map.
deba@2440
    54
  /// \param SupplyMap The type of the supply map.
deba@2440
    55
  ///
deba@2440
    56
  /// \warning
deba@2440
    57
  /// - Edge capacities and costs should be nonnegative integers.
deba@2440
    58
  ///	However \c CostMap::Value should be signed type.
kpeter@2509
    59
  /// - Supply values should be signed integers.
deba@2440
    60
  /// - \c LowerMap::Value must be convertible to
deba@2440
    61
  ///	\c CapacityMap::Value and \c CapacityMap::Value must be
deba@2440
    62
  ///	convertible to \c SupplyMap::Value.
deba@2440
    63
  ///
deba@2440
    64
  /// \author Peter Kovacs
deba@2440
    65
deba@2440
    66
template < typename Graph,
deba@2440
    67
	   typename LowerMap = typename Graph::template EdgeMap<int>,
deba@2440
    68
	   typename CapacityMap = LowerMap,
deba@2440
    69
	   typename CostMap = typename Graph::template EdgeMap<int>,
deba@2440
    70
	   typename SupplyMap = typename Graph::template NodeMap
deba@2440
    71
				<typename CapacityMap::Value> >
deba@2440
    72
  class MinCostFlow :
deba@2440
    73
    public NetworkSimplex< Graph,
deba@2440
    74
			   LowerMap,
deba@2440
    75
			   CapacityMap,
deba@2440
    76
			   CostMap,
deba@2440
    77
			   SupplyMap >
deba@2440
    78
  {
deba@2440
    79
    typedef NetworkSimplex< Graph, LowerMap, CapacityMap,
deba@2440
    80
			    CostMap, SupplyMap >
deba@2440
    81
      MinCostFlowImpl;
deba@2440
    82
    typedef typename Graph::Node Node;
deba@2440
    83
    typedef typename SupplyMap::Value Supply;
deba@2440
    84
deba@2440
    85
  public:
deba@2440
    86
deba@2440
    87
    /// \brief General constructor of the class (with lower bounds).
deba@2440
    88
    MinCostFlow( const Graph &_graph,
deba@2440
    89
		 const LowerMap &_lower,
deba@2440
    90
		 const CapacityMap &_capacity,
deba@2440
    91
		 const CostMap &_cost,
deba@2440
    92
		 const SupplyMap &_supply ) :
deba@2440
    93
      MinCostFlowImpl(_graph, _lower, _capacity, _cost, _supply) {}
deba@2440
    94
deba@2440
    95
    /// \brief General constructor of the class (without lower bounds).
deba@2440
    96
    MinCostFlow( const Graph &_graph,
deba@2440
    97
		 const CapacityMap &_capacity,
deba@2440
    98
		 const CostMap &_cost,
deba@2440
    99
		 const SupplyMap &_supply ) :
deba@2440
   100
      MinCostFlowImpl(_graph, _capacity, _cost, _supply) {}
deba@2440
   101
deba@2440
   102
    /// \brief Simple constructor of the class (with lower bounds).
deba@2440
   103
    MinCostFlow( const Graph &_graph,
deba@2440
   104
		 const LowerMap &_lower,
deba@2440
   105
		 const CapacityMap &_capacity,
deba@2440
   106
		 const CostMap &_cost,
deba@2440
   107
		 Node _s, Node _t,
deba@2440
   108
		 Supply _flow_value ) :
deba@2440
   109
      MinCostFlowImpl( _graph, _lower, _capacity, _cost,
deba@2440
   110
		       _s, _t, _flow_value ) {}
deba@2440
   111
deba@2440
   112
    /// \brief Simple constructor of the class (without lower bounds).
deba@2440
   113
    MinCostFlow( const Graph &_graph,
deba@2440
   114
		 const CapacityMap &_capacity,
deba@2440
   115
		 const CostMap &_cost,
deba@2440
   116
		 Node _s, Node _t,
deba@2440
   117
		 Supply _flow_value ) :
deba@2440
   118
      MinCostFlowImpl( _graph, _capacity, _cost,
deba@2440
   119
		       _s, _t, _flow_value ) {}
deba@2440
   120
deba@2440
   121
  }; //class MinCostFlow
deba@2440
   122
deba@2440
   123
  ///@}
deba@2440
   124
deba@2440
   125
} //namespace lemon
deba@2440
   126
deba@2440
   127
#endif //LEMON_MIN_COST_FLOW_H