COIN-OR::LEMON - Graph Library

Changes in / [488:b1ef32ab39f3:486:7d7d9debb29a] in lemon-1.2


Ignore:
Location:
lemon
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lemon/lgf_reader.h

    r487 r319  
    391391  class DigraphReader;
    392392
     393  /// \brief Return a \ref DigraphReader class
     394  ///
     395  /// This function just returns a \ref DigraphReader class.
     396  /// \relates DigraphReader
    393397  template <typename Digraph>
    394   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    395                                        std::istream& is = std::cin);
     398  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     399                                       std::istream& is = std::cin) {
     400    DigraphReader<Digraph> tmp(digraph, is);
     401    return tmp;
     402  }
     403
     404  /// \brief Return a \ref DigraphReader class
     405  ///
     406  /// This function just returns a \ref DigraphReader class.
     407  /// \relates DigraphReader
    396408  template <typename Digraph>
    397   DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
     409  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     410                                       const std::string& fn) {
     411    DigraphReader<Digraph> tmp(digraph, fn);
     412    return tmp;
     413  }
     414
     415  /// \brief Return a \ref DigraphReader class
     416  ///
     417  /// This function just returns a \ref DigraphReader class.
     418  /// \relates DigraphReader
    398419  template <typename Digraph>
    399   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
     420  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
     421    DigraphReader<Digraph> tmp(digraph, fn);
     422    return tmp;
     423  }
    400424
    401425  /// \ingroup lemon_io
     
    561585  private:
    562586
    563     template <typename DGR>
    564     friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
    565     template <typename DGR>
    566     friend DigraphReader<DGR> digraphReader(DGR& digraph,
    567                                             const std::string& fn);
    568     template <typename DGR>
    569     friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
     587    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     588                                                  std::istream& is);
     589    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     590                                                  const std::string& fn);
     591    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     592                                                  const char *fn);
    570593
    571594    DigraphReader(DigraphReader& other)
     
    11881211  };
    11891212
    1190   /// \brief Return a \ref DigraphReader class
     1213  template <typename Graph>
     1214  class GraphReader;
     1215
     1216  /// \brief Return a \ref GraphReader class
    11911217  ///
    1192   /// This function just returns a \ref DigraphReader class.
    1193   /// \relates DigraphReader
    1194   template <typename Digraph>
    1195   DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
    1196     DigraphReader<Digraph> tmp(digraph, is);
     1218  /// This function just returns a \ref GraphReader class.
     1219  /// \relates GraphReader
     1220  template <typename Graph>
     1221  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
     1222    GraphReader<Graph> tmp(graph, is);
    11971223    return tmp;
    11981224  }
    11991225
    1200   /// \brief Return a \ref DigraphReader class
     1226  /// \brief Return a \ref GraphReader class
    12011227  ///
    1202   /// This function just returns a \ref DigraphReader class.
    1203   /// \relates DigraphReader
    1204   template <typename Digraph>
    1205   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1206                                        const std::string& fn) {
    1207     DigraphReader<Digraph> tmp(digraph, fn);
     1228  /// This function just returns a \ref GraphReader class.
     1229  /// \relates GraphReader
     1230  template <typename Graph>
     1231  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
     1232    GraphReader<Graph> tmp(graph, fn);
    12081233    return tmp;
    12091234  }
    12101235
    1211   /// \brief Return a \ref DigraphReader class
     1236  /// \brief Return a \ref GraphReader class
    12121237  ///
    1213   /// This function just returns a \ref DigraphReader class.
    1214   /// \relates DigraphReader
    1215   template <typename Digraph>
    1216   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    1217     DigraphReader<Digraph> tmp(digraph, fn);
     1238  /// This function just returns a \ref GraphReader class.
     1239  /// \relates GraphReader
     1240  template <typename Graph>
     1241  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
     1242    GraphReader<Graph> tmp(graph, fn);
    12181243    return tmp;
    12191244  }
    1220 
    1221   template <typename Graph>
    1222   class GraphReader;
    1223  
    1224   template <typename Graph>
    1225   GraphReader<Graph> graphReader(Graph& graph,
    1226                                  std::istream& is = std::cin);
    1227   template <typename Graph>
    1228   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
    1229   template <typename Graph>
    1230   GraphReader<Graph> graphReader(Graph& graph, const char *fn);
    12311245
    12321246  /// \ingroup lemon_io
     
    13551369
    13561370  private:
    1357     template <typename GR>
    1358     friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
    1359     template <typename GR>
    1360     friend GraphReader<GR> graphReader(GR& graph, const std::string& fn);
    1361     template <typename GR>
    1362     friend GraphReader<GR> graphReader(GR& graph, const char *fn);
     1371    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
     1372    friend GraphReader<Graph> graphReader<>(Graph& graph,
     1373                                            const std::string& fn);
     1374    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
    13631375
    13641376    GraphReader(GraphReader& other)
     
    20282040
    20292041  };
    2030 
    2031   /// \brief Return a \ref GraphReader class
    2032   ///
    2033   /// This function just returns a \ref GraphReader class.
    2034   /// \relates GraphReader
    2035   template <typename Graph>
    2036   GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
    2037     GraphReader<Graph> tmp(graph, is);
    2038     return tmp;
    2039   }
    2040 
    2041   /// \brief Return a \ref GraphReader class
    2042   ///
    2043   /// This function just returns a \ref GraphReader class.
    2044   /// \relates GraphReader
    2045   template <typename Graph>
    2046   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
    2047     GraphReader<Graph> tmp(graph, fn);
    2048     return tmp;
    2049   }
    2050 
    2051   /// \brief Return a \ref GraphReader class
    2052   ///
    2053   /// This function just returns a \ref GraphReader class.
    2054   /// \relates GraphReader
    2055   template <typename Graph>
    2056   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
    2057     GraphReader<Graph> tmp(graph, fn);
    2058     return tmp;
    2059   }
    20602042
    20612043  class SectionReader;
  • lemon/lgf_writer.h

    r487 r319  
    351351  class DigraphWriter;
    352352
     353  /// \brief Return a \ref DigraphWriter class
     354  ///
     355  /// This function just returns a \ref DigraphWriter class.
     356  /// \relates DigraphWriter
    353357  template <typename Digraph>
    354358  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    355                                        std::ostream& os = std::cout);
     359                                       std::ostream& os = std::cout) {
     360    DigraphWriter<Digraph> tmp(digraph, os);
     361    return tmp;
     362  }
     363
     364  /// \brief Return a \ref DigraphWriter class
     365  ///
     366  /// This function just returns a \ref DigraphWriter class.
     367  /// \relates DigraphWriter
    356368  template <typename Digraph>
    357369  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    358                                        const std::string& fn);
    359 
     370                                       const std::string& fn) {
     371    DigraphWriter<Digraph> tmp(digraph, fn);
     372    return tmp;
     373  }
     374
     375  /// \brief Return a \ref DigraphWriter class
     376  ///
     377  /// This function just returns a \ref DigraphWriter class.
     378  /// \relates DigraphWriter
    360379  template <typename Digraph>
    361380  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    362                                        const char* fn);
    363 
     381                                       const char* fn) {
     382    DigraphWriter<Digraph> tmp(digraph, fn);
     383    return tmp;
     384  }
    364385
    365386  /// \ingroup lemon_io
     
    506527  private:
    507528
    508     template <typename DGR>
    509     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    510                                             std::ostream& os);
    511     template <typename DGR>
    512     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    513                                             const std::string& fn);
    514     template <typename DGR>
    515     friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    516                                             const char *fn);
     529    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     530                                                  std::ostream& os);
     531    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     532                                                  const std::string& fn);
     533    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     534                                                  const char *fn);
    517535
    518536    DigraphWriter(DigraphWriter& other)
     
    916934  };
    917935
    918   /// \brief Return a \ref DigraphWriter class
    919   ///
    920   /// This function just returns a \ref DigraphWriter class.
    921   /// \relates DigraphWriter
    922   template <typename Digraph>
    923   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    924                                        std::ostream& os) {
    925     DigraphWriter<Digraph> tmp(digraph, os);
     936  template <typename Graph>
     937  class GraphWriter;
     938
     939  /// \brief Return a \ref GraphWriter class
     940  ///
     941  /// This function just returns a \ref GraphWriter class.
     942  /// \relates GraphWriter
     943  template <typename Graph>
     944  GraphWriter<Graph> graphWriter(const Graph& graph,
     945                                 std::ostream& os = std::cout) {
     946    GraphWriter<Graph> tmp(graph, os);
    926947    return tmp;
    927948  }
    928949
    929   /// \brief Return a \ref DigraphWriter class
    930   ///
    931   /// This function just returns a \ref DigraphWriter class.
    932   /// \relates DigraphWriter
    933   template <typename Digraph>
    934   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    935                                        const std::string& fn) {
    936     DigraphWriter<Digraph> tmp(digraph, fn);
     950  /// \brief Return a \ref GraphWriter class
     951  ///
     952  /// This function just returns a \ref GraphWriter class.
     953  /// \relates GraphWriter
     954  template <typename Graph>
     955  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
     956    GraphWriter<Graph> tmp(graph, fn);
    937957    return tmp;
    938958  }
    939959
    940   /// \brief Return a \ref DigraphWriter class
    941   ///
    942   /// This function just returns a \ref DigraphWriter class.
    943   /// \relates DigraphWriter
    944   template <typename Digraph>
    945   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    946                                        const char* fn) {
    947     DigraphWriter<Digraph> tmp(digraph, fn);
     960  /// \brief Return a \ref GraphWriter class
     961  ///
     962  /// This function just returns a \ref GraphWriter class.
     963  /// \relates GraphWriter
     964  template <typename Graph>
     965  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
     966    GraphWriter<Graph> tmp(graph, fn);
    948967    return tmp;
    949968  }
    950 
    951   template <typename Graph>
    952   class GraphWriter;
    953 
    954   template <typename Graph>
    955   GraphWriter<Graph> graphWriter(const Graph& graph,
    956                                  std::ostream& os = std::cout);
    957   template <typename Graph>
    958   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
    959   template <typename Graph>
    960   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
    961969
    962970  /// \ingroup lemon_io
     
    10741082  private:
    10751083
    1076     template <typename GR>
    1077     friend GraphWriter<GR> graphWriter(const GR& graph,
    1078                                        std::ostream& os);
    1079     template <typename GR>
    1080     friend GraphWriter<GR> graphWriter(const GR& graph,
    1081                                        const std::string& fn);
    1082     template <typename GR>
    1083     friend GraphWriter<GR> graphWriter(const GR& graph,
    1084                                        const char *fn);
    1085    
     1084    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1085                                            std::ostream& os);
     1086    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1087                                            const std::string& fn);
     1088    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1089                                            const char *fn);
     1090
    10861091    GraphWriter(GraphWriter& other)
    10871092      : _os(other._os), local_os(other.local_os), _graph(other._graph),
     
    15291534    /// @}
    15301535  };
    1531 
    1532   /// \brief Return a \ref GraphWriter class
    1533   ///
    1534   /// This function just returns a \ref GraphWriter class.
    1535   /// \relates GraphWriter
    1536   template <typename Graph>
    1537   GraphWriter<Graph> graphWriter(const Graph& graph,
    1538                                  std::ostream& os) {
    1539     GraphWriter<Graph> tmp(graph, os);
    1540     return tmp;
    1541   }
    1542 
    1543   /// \brief Return a \ref GraphWriter class
    1544   ///
    1545   /// This function just returns a \ref GraphWriter class.
    1546   /// \relates GraphWriter
    1547   template <typename Graph>
    1548   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
    1549     GraphWriter<Graph> tmp(graph, fn);
    1550     return tmp;
    1551   }
    1552 
    1553   /// \brief Return a \ref GraphWriter class
    1554   ///
    1555   /// This function just returns a \ref GraphWriter class.
    1556   /// \relates GraphWriter
    1557   template <typename Graph>
    1558   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
    1559     GraphWriter<Graph> tmp(graph, fn);
    1560     return tmp;
    1561   }
    15621536
    15631537  class SectionWriter;
  • lemon/path.h

    r487 r313  
    930930
    931931    template <typename Target, typename Source,
    932               bool buildEnable = BuildTagIndicator<Target>::value>
    933     struct PathCopySelectorForward {
     932              bool buildEnable = BuildTagIndicator<Target>::value,
     933              bool revEnable = RevPathTagIndicator<Source>::value>
     934    struct PathCopySelector {
    934935      static void copy(Target& target, const Source& source) {
    935936        target.clear();
     
    941942
    942943    template <typename Target, typename Source>
    943     struct PathCopySelectorForward<Target, Source, true> {
    944       static void copy(Target& target, const Source& source) {
    945         target.clear();
    946         target.build(source);
    947       }
    948     };
    949 
    950     template <typename Target, typename Source,
    951               bool buildEnable = BuildTagIndicator<Target>::value>
    952     struct PathCopySelectorBackward {
     944    struct PathCopySelector<Target, Source, false, true> {
    953945      static void copy(Target& target, const Source& source) {
    954946        target.clear();
     
    960952
    961953    template <typename Target, typename Source>
    962     struct PathCopySelectorBackward<Target, Source, true> {
     954    struct PathCopySelector<Target, Source, true, false> {
     955      static void copy(Target& target, const Source& source) {
     956        target.clear();
     957        target.build(source);
     958      }
     959    };
     960
     961    template <typename Target, typename Source>
     962    struct PathCopySelector<Target, Source, true, true> {
    963963      static void copy(Target& target, const Source& source) {
    964964        target.clear();
    965965        target.buildRev(source);
    966966      }
    967     };
    968 
    969    
    970     template <typename Target, typename Source,
    971               bool revEnable = RevPathTagIndicator<Source>::value>
    972     struct PathCopySelector {
    973       static void copy(Target& target, const Source& source) {
    974         PathCopySelectorForward<Target, Source>::copy(target, source);
    975       }     
    976     };
    977 
    978     template <typename Target, typename Source>
    979     struct PathCopySelector<Target, Source, true> {
    980       static void copy(Target& target, const Source& source) {
    981         PathCopySelectorBackward<Target, Source>::copy(target, source);
    982       }     
    983967    };
    984968
  • lemon/random.h

    r487 r482  
    345345    };
    346346
     347    template <typename Result, int exp, bool pos = (exp >= 0)>
     348    struct ShiftMultiplier {
     349      static const Result multiplier() {
     350        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
     351        res *= res;
     352        if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
     353        return res;
     354      }
     355    };
     356
    347357    template <typename Result, int exp>
    348     struct ShiftMultiplier {
     358    struct ShiftMultiplier<Result, exp, false> {
    349359      static const Result multiplier() {
    350360        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
     
    356366
    357367    template <typename Result>
    358     struct ShiftMultiplier<Result, 0> {
     368    struct ShiftMultiplier<Result, 0, true> {
    359369      static const Result multiplier() {
    360370        return static_cast<Result>(1.0);
     
    363373
    364374    template <typename Result>
    365     struct ShiftMultiplier<Result, 20> {
     375    struct ShiftMultiplier<Result, -20, true> {
    366376      static const Result multiplier() {
    367377        return static_cast<Result>(1.0/1048576.0);
     
    370380
    371381    template <typename Result>
    372     struct ShiftMultiplier<Result, 32> {
     382    struct ShiftMultiplier<Result, -32, true> {
    373383      static const Result multiplier() {
    374         return static_cast<Result>(1.0/4294967296.0);
     384        return static_cast<Result>(1.0/424967296.0);
    375385      }
    376386    };
    377387
    378388    template <typename Result>
    379     struct ShiftMultiplier<Result, 53> {
     389    struct ShiftMultiplier<Result, -53, true> {
    380390      static const Result multiplier() {
    381391        return static_cast<Result>(1.0/9007199254740992.0);
     
    384394
    385395    template <typename Result>
    386     struct ShiftMultiplier<Result, 64> {
     396    struct ShiftMultiplier<Result, -64, true> {
    387397      static const Result multiplier() {
    388398        return static_cast<Result>(1.0/18446744073709551616.0);
     
    404414
    405415      static Result convert(RandomCore<Word>& rnd) {
    406         return Shifting<Result, shift + rest>::
     416        return Shifting<Result, - shift - rest>::
    407417          shift(static_cast<Result>(rnd() >> (bits - rest)));
    408418      }
     
    414424
    415425      static Result convert(RandomCore<Word>& rnd) {
    416         return Shifting<Result, shift + bits>::
     426        return Shifting<Result, - shift - bits>::
    417427          shift(static_cast<Result>(rnd())) +
    418428          RealConversion<Result, Word, rest-bits, shift + bits>::
Note: See TracChangeset for help on using the changeset viewer.