lemon/dimacs.h
changeset 401 9d1faab5e0f1
parent 400 50d96f2166d7
child 402 24a2c6ee6cb0
equal deleted inserted replaced
0:577ddc39e651 1:526165c10967
    52   /// lower bounds, capacities and costs of the arcs are written to
    52   /// lower bounds, capacities and costs of the arcs are written to
    53   /// \c lower, \c capacity and \c cost.
    53   /// \c lower, \c capacity and \c cost.
    54   template <typename Digraph, typename LowerMap,
    54   template <typename Digraph, typename LowerMap,
    55     typename CapacityMap, typename CostMap,
    55     typename CapacityMap, typename CostMap,
    56     typename SupplyMap>
    56     typename SupplyMap>
    57   void readDimacs( std::istream& is,
    57   void readDimacsMin( std::istream& is,
    58                    Digraph &g,
    58                    Digraph &g,
    59                    LowerMap& lower,
    59                    LowerMap& lower,
    60                    CapacityMap& capacity,
    60                    CapacityMap& capacity,
    61                    CostMap& cost,
    61                    CostMap& cost,
    62                    SupplyMap& supply )
    62                    SupplyMap& supply )
   116   /// \endcode
   116   /// \endcode
   117   /// At the beginning \c g is cleared by \c g.clear(). The arc
   117   /// At the beginning \c g is cleared by \c g.clear(). The arc
   118   /// capacities are written to \c capacity and \c s and \c t are
   118   /// capacities are written to \c capacity and \c s and \c t are
   119   /// set to the source and the target nodes.
   119   /// set to the source and the target nodes.
   120   template<typename Digraph, typename CapacityMap>
   120   template<typename Digraph, typename CapacityMap>
   121   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity,
   121   void readDimacsMax(std::istream& is, Digraph &g, CapacityMap& capacity,
   122                   typename Digraph::Node &s, typename Digraph::Node &t) {
   122                   typename Digraph::Node &s, typename Digraph::Node &t) {
   123     g.clear();
   123     g.clear();
   124     std::vector<typename Digraph::Node> nodes;
   124     std::vector<typename Digraph::Node> nodes;
   125     typename Digraph::Arc e;
   125     typename Digraph::Arc e;
   126     std::string problem;
   126     std::string problem;
   179   /// \endcode
   179   /// \endcode
   180   /// At the beginning \c g is cleared by \c g.clear(). The arc
   180   /// At the beginning \c g is cleared by \c g.clear(). The arc
   181   /// capacities are written to \c capacity and \c s is set to the
   181   /// capacities are written to \c capacity and \c s is set to the
   182   /// source node.
   182   /// source node.
   183   template<typename Digraph, typename CapacityMap>
   183   template<typename Digraph, typename CapacityMap>
   184   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity,
   184   void readDimacsSp(std::istream& is, Digraph &g, CapacityMap& capacity,
   185                   typename Digraph::Node &s) {
   185                   typename Digraph::Node &s) {
   186     readDimacs(is, g, capacity, s, s);
   186     typename Digraph::Node t;
       
   187     readDimacsMax(is, g, capacity, s, t);
   187   }
   188   }
   188 
   189 
   189   /// DIMACS capacitated digraph reader function.
   190   /// DIMACS capacitated digraph reader function.
   190   ///
   191   ///
   191   /// This function reads an arc capacitated digraph instance from
   192   /// This function reads an arc capacitated digraph instance from
   192   /// DIMACS format. At the beginning \c g is cleared by \c g.clear()
   193   /// DIMACS format. At the beginning \c g is cleared by \c g.clear()
   193   /// and the arc capacities are written to \c capacity.
   194   /// and the arc capacities are written to \c capacity.
   194   template<typename Digraph, typename CapacityMap>
   195   template<typename Digraph, typename CapacityMap>
   195   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity) {
   196   void readDimacsMax(std::istream& is, Digraph &g, CapacityMap& capacity) {
   196     typename Digraph::Node u;
   197     typename Digraph::Node u,v;
   197     readDimacs(is, g, capacity, u, u);
   198     readDimacsMax(is, g, capacity, u, v);
   198   }
   199   }
   199 
   200 
   200   /// DIMACS plain digraph reader function.
   201   /// DIMACS plain digraph reader function.
   201   ///
   202   ///
   202   /// This function reads a digraph without any designated nodes and
   203   /// This function reads a digraph without any designated nodes and
   205   /// \code
   206   /// \code
   206   ///   p mat
   207   ///   p mat
   207   /// \endcode
   208   /// \endcode
   208   /// At the beginning \c g is cleared by \c g.clear().
   209   /// At the beginning \c g is cleared by \c g.clear().
   209   template<typename Digraph>
   210   template<typename Digraph>
   210   void readDimacs(std::istream& is, Digraph &g) {
   211   void readDimacsMat(std::istream& is, Digraph &g) {
   211     typename Digraph::Node u;
   212     typename Digraph::Node u,v;
   212     NullMap<typename Digraph::Arc, int> n;
   213     NullMap<typename Digraph::Arc, int> n;
   213     readDimacs(is, g, n, u, u);
   214     readDimacsMax(is, g, n, u, v);
   214   }
   215   }
   215 
   216 
   216   /// DIMACS plain digraph writer function.
   217   /// DIMACS plain digraph writer function.
   217   ///
   218   ///
   218   /// This function writes a digraph without any designated nodes and
   219   /// This function writes a digraph without any designated nodes and
   220   /// starting with
   221   /// starting with
   221   /// \code
   222   /// \code
   222   ///   p mat
   223   ///   p mat
   223   /// \endcode
   224   /// \endcode
   224   template<typename Digraph>
   225   template<typename Digraph>
   225   void writeDimacs(std::ostream& os, const Digraph &g) {
   226   void writeDimacsMat(std::ostream& os, const Digraph &g) {
   226     typedef typename Digraph::NodeIt NodeIt;
   227     typedef typename Digraph::NodeIt NodeIt;
   227     typedef typename Digraph::ArcIt ArcIt;
   228     typedef typename Digraph::ArcIt ArcIt;
   228 
   229 
   229     os << "c matching problem" << std::endl;
   230     os << "c matching problem" << std::endl;
   230     os << "p mat " << g.nodeNum() << " " << g.arcNum() << std::endl;
   231     os << "p mat " << g.nodeNum() << " " << g.arcNum() << std::endl;