COIN-OR::LEMON - Graph Library

Ticket #167: a6bc90e888ff.patch

File a6bc90e888ff.patch, 4.2 KB (added by Alpar Juttner, 11 years ago)

Port of DIMACS stuff

  • lemon/dimacs.h

    # HG changeset patch
    # User Alpar Juttner <alpar@cs.elte.hu>
    # Date 1227619306 0
    # Node ID a6bc90e888ff4d0ecfba4c9dce06f9bf31812f8a
    # Parent  c052e6718a958fb724f783c90f55f551973204f7
    Give different names to the different DIMACS readers
    
    diff --git a/lemon/dimacs.h b/lemon/dimacs.h
    a b  
    5656  template <typename Digraph, typename LowerMap,
    5757    typename CapacityMap, typename CostMap,
    5858    typename SupplyMap>
    59   void readDimacs( std::istream& is,
     59  void readDimacsMin( std::istream& is,
    6060                   Digraph &g,
    6161                   LowerMap& lower,
    6262                   CapacityMap& capacity,
     
    122122  ///
    123123  /// \author Marton Makai
    124124  template<typename Digraph, typename CapacityMap>
    125   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity,
     125  void readDimacsMax(std::istream& is, Digraph &g, CapacityMap& capacity,
    126126                  typename Digraph::Node &s, typename Digraph::Node &t) {
    127127    g.clear();
    128128    std::vector<typename Digraph::Node> nodes;
     
    187187  ///
    188188  /// \author Marton Makai
    189189  template<typename Digraph, typename CapacityMap>
    190   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity,
     190  void readDimacsSp(std::istream& is, Digraph &g, CapacityMap& capacity,
    191191                  typename Digraph::Node &s) {
    192     readDimacs(is, g, capacity, s, s);
     192    typename Digraph::Node t;
     193    readDimacsMax(is, g, capacity, s, t);
    193194  }
    194195
    195196  /// DIMACS capacitated digraph reader function.
     
    200201  ///
    201202  /// \author Marton Makai
    202203  template<typename Digraph, typename CapacityMap>
    203   void readDimacs(std::istream& is, Digraph &g, CapacityMap& capacity) {
    204     typename Digraph::Node u;
    205     readDimacs(is, g, capacity, u, u);
     204  void readDimacsMax(std::istream& is, Digraph &g, CapacityMap& capacity) {
     205    typename Digraph::Node u,v;
     206    readDimacsMax(is, g, capacity, u, v);
    206207  }
    207208
    208209  /// DIMACS plain digraph reader function.
     
    217218  ///
    218219  /// \author Marton Makai
    219220  template<typename Digraph>
    220   void readDimacs(std::istream& is, Digraph &g) {
    221     typename Digraph::Node u;
     221  void readDimacsMat(std::istream& is, Digraph &g) {
     222    typename Digraph::Node u,v;
    222223    NullMap<typename Digraph::Arc, int> n;
    223     readDimacs(is, g, n, u, u);
     224    readDimacsMax(is, g, n, u, v);
    224225  }
    225226
    226227  /// DIMACS plain digraph writer function.
     
    234235  ///
    235236  /// \author Marton Makai
    236237  template<typename Digraph>
    237   void writeDimacs(std::ostream& os, const Digraph &g) {
     238  void writeDimacsMat(std::ostream& os, const Digraph &g) {
    238239    typedef typename Digraph::NodeIt NodeIt;
    239240    typedef typename Digraph::ArcIt ArcIt;
    240241
  • tools/dimacs-to-lgf.cc

    diff --git a/tools/dimacs-to-lgf.cc b/tools/dimacs-to-lgf.cc
    a b  
    123123    Digraph digraph;
    124124    DoubleArcMap lower(digraph), capacity(digraph), cost(digraph);
    125125    DoubleNodeMap supply(digraph);
    126     readDimacs(is, digraph, lower, capacity, cost, supply);
     126    readDimacsMin(is, digraph, lower, capacity, cost, supply);
    127127    DigraphWriter<Digraph>(digraph, os).
    128128      nodeMap("supply", supply).
    129129      arcMap("lower", lower).
     
    134134    Digraph digraph;
    135135    Node s, t;
    136136    DoubleArcMap capacity(digraph);
    137     readDimacs(is, digraph, capacity, s, t);
     137    readDimacsMax(is, digraph, capacity, s, t);
    138138    DigraphWriter<Digraph>(digraph, os).
    139139      arcMap("capacity", capacity).
    140140      node("source", s).
     
    144144    Digraph digraph;
    145145    Node s;
    146146    DoubleArcMap capacity(digraph);
    147     readDimacs(is, digraph, capacity, s);
     147    readDimacsSp(is, digraph, capacity, s);
    148148    DigraphWriter<Digraph>(digraph, os).
    149149      arcMap("capacity", capacity).
    150150      node("source", s).
     
    152152  } else if (capacitated) {
    153153    Digraph digraph;
    154154    DoubleArcMap capacity(digraph);
    155     readDimacs(is, digraph, capacity);
     155    readDimacsMax(is, digraph, capacity);
    156156    DigraphWriter<Digraph>(digraph, os).
    157157      arcMap("capacity", capacity).
    158158      run();
    159159  } else if (plain) {
    160160    Digraph digraph;
    161     readDimacs(is, digraph);
     161    readDimacsMat(is, digraph);
    162162    DigraphWriter<Digraph>(digraph, os).run();
    163163  } else {
    164164    cerr << "Invalid type error" << endl;