Merge
authorAlpar Juttner <alpar@cs.elte.hu>
Fri, 20 Feb 2009 21:37:19 +0000
changeset 5172b6d5d22bb23
parent 495 dab9e610e37d
parent 499 b1ef32ab39f3
child 518 8668e1b5dafb
Merge
.hgignore
CMakeLists.txt
configure.ac
lemon/bits/default_map.h
lemon/config.h.cmake
lemon/config.h.in
lemon/lgf_reader.h
lemon/lgf_writer.h
lemon/path.h
lemon/random.h
lemon/tolerance.h
     1.1 --- a/.hgignore	Fri Feb 20 18:43:34 2009 +0100
     1.2 +++ b/.hgignore	Fri Feb 20 21:37:19 2009 +0000
     1.3 @@ -22,6 +22,7 @@
     1.4  lemon/libemon.la
     1.5  lemon/stamp-h2
     1.6  doc/Doxyfile
     1.7 +cmake/cmake.version
     1.8  .dirstamp
     1.9  .libs/*
    1.10  .deps/*
     2.1 --- a/CMakeLists.txt	Fri Feb 20 18:43:34 2009 +0100
     2.2 +++ b/CMakeLists.txt	Fri Feb 20 21:37:19 2009 +0000
     2.3 @@ -32,6 +32,9 @@
     2.4    SET(HAVE_GLPK TRUE)
     2.5  ENDIF(GLPK_FOUND)
     2.6  
     2.7 +INCLUDE(CheckTypeSize)
     2.8 +CHECK_TYPE_SIZE("long long" LONG_LONG)
     2.9 +
    2.10  ENABLE_TESTING()
    2.11  
    2.12  ADD_SUBDIRECTORY(lemon)
     3.1 --- a/configure.ac	Fri Feb 20 18:43:34 2009 +0100
     3.2 +++ b/configure.ac	Fri Feb 20 21:37:19 2009 +0000
     3.3 @@ -22,6 +22,12 @@
     3.4  dnl Do compilation tests using the C++ compiler.
     3.5  AC_LANG([C++])
     3.6  
     3.7 +dnl Check the existence of long long type.
     3.8 +AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
     3.9 +if test x"$long_long_found" = x"yes"; then
    3.10 +  AC_DEFINE([HAVE_LONG_LONG], [1], [Define to 1 if you have long long.])
    3.11 +fi
    3.12 +
    3.13  dnl Checks for programs.
    3.14  AC_PROG_CXX
    3.15  AC_PROG_CXXCPP
    3.16 @@ -119,6 +125,8 @@
    3.17  echo C++ compiler.................. : $CXX
    3.18  echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
    3.19  echo
    3.20 +echo Compiler supports long long... : $long_long_found
    3.21 +echo
    3.22  echo GLPK support.................. : $lx_glpk_found
    3.23  echo CPLEX support................. : $lx_cplex_found
    3.24  echo SOPLEX support................ : $lx_soplex_found
     4.1 --- a/lemon/bits/default_map.h	Fri Feb 20 18:43:34 2009 +0100
     4.2 +++ b/lemon/bits/default_map.h	Fri Feb 20 21:37:19 2009 +0000
     4.3 @@ -96,7 +96,7 @@
     4.4    };
     4.5  
     4.6  
     4.7 -#if defined __GNUC__ && !defined __STRICT_ANSI__
     4.8 +#if defined HAVE_LONG_LONG
     4.9  
    4.10    // long long
    4.11    template <typename _Graph, typename _Item>
     5.1 --- a/lemon/bits/windows.cc	Fri Feb 20 18:43:34 2009 +0100
     5.2 +++ b/lemon/bits/windows.cc	Fri Feb 20 21:37:19 2009 +0000
     5.3 @@ -28,7 +28,15 @@
     5.4  #ifndef NOMINMAX
     5.5  #define NOMINMAX
     5.6  #endif
     5.7 +#ifdef UNICODE
     5.8 +#undef UNICODE
     5.9 +#endif
    5.10  #include <windows.h>
    5.11 +#ifdef LOCALE_INVARIANT
    5.12 +#define MY_LOCALE LOCALE_INVARIANT
    5.13 +#else
    5.14 +#define MY_LOCALE LOCALE_NEUTRAL
    5.15 +#endif
    5.16  #else
    5.17  #include <unistd.h>
    5.18  #include <ctime>
    5.19 @@ -87,27 +95,15 @@
    5.20  #ifdef WIN32
    5.21        SYSTEMTIME time;
    5.22        GetSystemTime(&time);
    5.23 -#if defined(_MSC_VER) && (_MSC_VER < 1500)
    5.24 -      LPWSTR buf1, buf2, buf3;
    5.25 -      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.26 -                        L"ddd MMM dd", buf1, 11) &&
    5.27 -          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.28 -                        L"HH':'mm':'ss", buf2, 9) &&
    5.29 -          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.30 -                        L"yyyy", buf3, 5)) {
    5.31 +      char buf1[11], buf2[9], buf3[5];
    5.32 +	  if (GetDateFormat(MY_LOCALE, 0, &time,
    5.33 +                        ("ddd MMM dd"), buf1, 11) &&
    5.34 +          GetTimeFormat(MY_LOCALE, 0, &time,
    5.35 +                        ("HH':'mm':'ss"), buf2, 9) &&
    5.36 +          GetDateFormat(MY_LOCALE, 0, &time,
    5.37 +                        ("yyyy"), buf3, 5)) {
    5.38          os << buf1 << ' ' << buf2 << ' ' << buf3;
    5.39        }
    5.40 -#else
    5.41 -      char buf1[11], buf2[9], buf3[5];
    5.42 -      if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.43 -                        "ddd MMM dd", buf1, 11) &&
    5.44 -          GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.45 -                        "HH':'mm':'ss", buf2, 9) &&
    5.46 -          GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
    5.47 -                        "yyyy", buf3, 5)) {
    5.48 -        os << buf1 << ' ' << buf2 << ' ' << buf3;
    5.49 -      }
    5.50 -#endif
    5.51        else os << "unknown";
    5.52  #else
    5.53        timeval tv;
     6.1 --- a/lemon/config.h.cmake	Fri Feb 20 18:43:34 2009 +0100
     6.2 +++ b/lemon/config.h.cmake	Fri Feb 20 21:37:19 2009 +0000
     6.3 @@ -1,3 +1,4 @@
     6.4 -#cmakedefine HAVE_LP 1
     6.5 -#cmakedefine HAVE_MIP 1
     6.6 -#cmakedefine HAVE_GLPK 1
     6.7 +#cmakedefine HAVE_LONG_LONG 1
     6.8 +#cmakedefine HAVE_LP 1
     6.9 +#cmakedefine HAVE_MIP 1
    6.10 +#cmakedefine HAVE_GLPK 1
     7.1 --- a/lemon/config.h.in	Fri Feb 20 18:43:34 2009 +0100
     7.2 +++ b/lemon/config.h.in	Fri Feb 20 21:37:19 2009 +0000
     7.3 @@ -1,3 +1,6 @@
     7.4 +/* Define to 1 if you have long long */
     7.5 +#undef HAVE_LONG_LONG
     7.6 +
     7.7  /* Define to 1 if you have any LP solver. */
     7.8  #undef HAVE_LP
     7.9  
     8.1 --- a/lemon/lgf_reader.h	Fri Feb 20 18:43:34 2009 +0100
     8.2 +++ b/lemon/lgf_reader.h	Fri Feb 20 21:37:19 2009 +0000
     8.3 @@ -390,37 +390,13 @@
     8.4    template <typename Digraph>
     8.5    class DigraphReader;
     8.6  
     8.7 -  /// \brief Return a \ref DigraphReader class
     8.8 -  ///
     8.9 -  /// This function just returns a \ref DigraphReader class.
    8.10 -  /// \relates DigraphReader
    8.11    template <typename Digraph>
    8.12 -  DigraphReader<Digraph> digraphReader(Digraph& digraph,
    8.13 -                                       std::istream& is = std::cin) {
    8.14 -    DigraphReader<Digraph> tmp(digraph, is);
    8.15 -    return tmp;
    8.16 -  }
    8.17 -
    8.18 -  /// \brief Return a \ref DigraphReader class
    8.19 -  ///
    8.20 -  /// This function just returns a \ref DigraphReader class.
    8.21 -  /// \relates DigraphReader
    8.22 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, 
    8.23 +                                       std::istream& is = std::cin);
    8.24    template <typename Digraph>
    8.25 -  DigraphReader<Digraph> digraphReader(Digraph& digraph,
    8.26 -                                       const std::string& fn) {
    8.27 -    DigraphReader<Digraph> tmp(digraph, fn);
    8.28 -    return tmp;
    8.29 -  }
    8.30 -
    8.31 -  /// \brief Return a \ref DigraphReader class
    8.32 -  ///
    8.33 -  /// This function just returns a \ref DigraphReader class.
    8.34 -  /// \relates DigraphReader
    8.35 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
    8.36    template <typename Digraph>
    8.37 -  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    8.38 -    DigraphReader<Digraph> tmp(digraph, fn);
    8.39 -    return tmp;
    8.40 -  }
    8.41 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
    8.42  
    8.43    /// \ingroup lemon_io
    8.44    ///
    8.45 @@ -584,12 +560,13 @@
    8.46  
    8.47    private:
    8.48  
    8.49 -    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    8.50 -                                                  std::istream& is);
    8.51 -    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    8.52 -                                                  const std::string& fn);
    8.53 -    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
    8.54 -                                                  const char *fn);
    8.55 +    template <typename DGR>
    8.56 +    friend DigraphReader<DGR> digraphReader(DGR& digraph, std::istream& is);
    8.57 +    template <typename DGR>
    8.58 +    friend DigraphReader<DGR> digraphReader(DGR& digraph, 
    8.59 +                                            const std::string& fn);
    8.60 +    template <typename DGR>
    8.61 +    friend DigraphReader<DGR> digraphReader(DGR& digraph, const char *fn);
    8.62  
    8.63      DigraphReader(DigraphReader& other)
    8.64        : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
    8.65 @@ -1212,38 +1189,47 @@
    8.66  
    8.67    };
    8.68  
    8.69 +  /// \brief Return a \ref DigraphReader class
    8.70 +  ///
    8.71 +  /// This function just returns a \ref DigraphReader class.
    8.72 +  /// \relates DigraphReader
    8.73 +  template <typename Digraph>
    8.74 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, std::istream& is) {
    8.75 +    DigraphReader<Digraph> tmp(digraph, is);
    8.76 +    return tmp;
    8.77 +  }
    8.78 +
    8.79 +  /// \brief Return a \ref DigraphReader class
    8.80 +  ///
    8.81 +  /// This function just returns a \ref DigraphReader class.
    8.82 +  /// \relates DigraphReader
    8.83 +  template <typename Digraph>
    8.84 +  DigraphReader<Digraph> digraphReader(Digraph& digraph,
    8.85 +                                       const std::string& fn) {
    8.86 +    DigraphReader<Digraph> tmp(digraph, fn);
    8.87 +    return tmp;
    8.88 +  }
    8.89 +
    8.90 +  /// \brief Return a \ref DigraphReader class
    8.91 +  ///
    8.92 +  /// This function just returns a \ref DigraphReader class.
    8.93 +  /// \relates DigraphReader
    8.94 +  template <typename Digraph>
    8.95 +  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    8.96 +    DigraphReader<Digraph> tmp(digraph, fn);
    8.97 +    return tmp;
    8.98 +  }
    8.99 +
   8.100    template <typename Graph>
   8.101    class GraphReader;
   8.102 -
   8.103 -  /// \brief Return a \ref GraphReader class
   8.104 -  ///
   8.105 -  /// This function just returns a \ref GraphReader class.
   8.106 -  /// \relates GraphReader
   8.107 + 
   8.108    template <typename Graph>
   8.109 -  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
   8.110 -    GraphReader<Graph> tmp(graph, is);
   8.111 -    return tmp;
   8.112 -  }
   8.113 -
   8.114 -  /// \brief Return a \ref GraphReader class
   8.115 -  ///
   8.116 -  /// This function just returns a \ref GraphReader class.
   8.117 -  /// \relates GraphReader
   8.118 +  GraphReader<Graph> graphReader(Graph& graph, 
   8.119 +                                 std::istream& is = std::cin);
   8.120    template <typename Graph>
   8.121 -  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
   8.122 -    GraphReader<Graph> tmp(graph, fn);
   8.123 -    return tmp;
   8.124 -  }
   8.125 -
   8.126 -  /// \brief Return a \ref GraphReader class
   8.127 -  ///
   8.128 -  /// This function just returns a \ref GraphReader class.
   8.129 -  /// \relates GraphReader
   8.130 +  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
   8.131    template <typename Graph>
   8.132 -  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
   8.133 -    GraphReader<Graph> tmp(graph, fn);
   8.134 -    return tmp;
   8.135 -  }
   8.136 +  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
   8.137  
   8.138    /// \ingroup lemon_io
   8.139    ///
   8.140 @@ -1370,10 +1356,12 @@
   8.141      }
   8.142  
   8.143    private:
   8.144 -    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
   8.145 -    friend GraphReader<Graph> graphReader<>(Graph& graph,
   8.146 -                                            const std::string& fn);
   8.147 -    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
   8.148 +    template <typename GR>
   8.149 +    friend GraphReader<GR> graphReader(GR& graph, std::istream& is);
   8.150 +    template <typename GR>
   8.151 +    friend GraphReader<GR> graphReader(GR& graph, const std::string& fn); 
   8.152 +    template <typename GR>
   8.153 +    friend GraphReader<GR> graphReader(GR& graph, const char *fn);
   8.154  
   8.155      GraphReader(GraphReader& other)
   8.156        : _is(other._is), local_is(other.local_is), _graph(other._graph),
   8.157 @@ -2044,6 +2032,36 @@
   8.158  
   8.159    };
   8.160  
   8.161 +  /// \brief Return a \ref GraphReader class
   8.162 +  ///
   8.163 +  /// This function just returns a \ref GraphReader class.
   8.164 +  /// \relates GraphReader
   8.165 +  template <typename Graph>
   8.166 +  GraphReader<Graph> graphReader(Graph& graph, std::istream& is) {
   8.167 +    GraphReader<Graph> tmp(graph, is);
   8.168 +    return tmp;
   8.169 +  }
   8.170 +
   8.171 +  /// \brief Return a \ref GraphReader class
   8.172 +  ///
   8.173 +  /// This function just returns a \ref GraphReader class.
   8.174 +  /// \relates GraphReader
   8.175 +  template <typename Graph>
   8.176 +  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
   8.177 +    GraphReader<Graph> tmp(graph, fn);
   8.178 +    return tmp;
   8.179 +  }
   8.180 +
   8.181 +  /// \brief Return a \ref GraphReader class
   8.182 +  ///
   8.183 +  /// This function just returns a \ref GraphReader class.
   8.184 +  /// \relates GraphReader
   8.185 +  template <typename Graph>
   8.186 +  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
   8.187 +    GraphReader<Graph> tmp(graph, fn);
   8.188 +    return tmp;
   8.189 +  }
   8.190 +
   8.191    class SectionReader;
   8.192  
   8.193    SectionReader sectionReader(std::istream& is);
     9.1 --- a/lemon/lgf_writer.h	Fri Feb 20 18:43:34 2009 +0100
     9.2 +++ b/lemon/lgf_writer.h	Fri Feb 20 21:37:19 2009 +0000
     9.3 @@ -350,38 +350,17 @@
     9.4    template <typename Digraph>
     9.5    class DigraphWriter;
     9.6  
     9.7 -  /// \brief Return a \ref DigraphWriter class
     9.8 -  ///
     9.9 -  /// This function just returns a \ref DigraphWriter class.
    9.10 -  /// \relates DigraphWriter
    9.11    template <typename Digraph>
    9.12    DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    9.13 -                                       std::ostream& os = std::cout) {
    9.14 -    DigraphWriter<Digraph> tmp(digraph, os);
    9.15 -    return tmp;
    9.16 -  }
    9.17 -
    9.18 -  /// \brief Return a \ref DigraphWriter class
    9.19 -  ///
    9.20 -  /// This function just returns a \ref DigraphWriter class.
    9.21 -  /// \relates DigraphWriter
    9.22 +                                       std::ostream& os = std::cout);
    9.23    template <typename Digraph>
    9.24    DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    9.25 -                                       const std::string& fn) {
    9.26 -    DigraphWriter<Digraph> tmp(digraph, fn);
    9.27 -    return tmp;
    9.28 -  }
    9.29 +                                       const std::string& fn);
    9.30  
    9.31 -  /// \brief Return a \ref DigraphWriter class
    9.32 -  ///
    9.33 -  /// This function just returns a \ref DigraphWriter class.
    9.34 -  /// \relates DigraphWriter
    9.35    template <typename Digraph>
    9.36    DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    9.37 -                                       const char* fn) {
    9.38 -    DigraphWriter<Digraph> tmp(digraph, fn);
    9.39 -    return tmp;
    9.40 -  }
    9.41 +                                       const char* fn);
    9.42 +
    9.43  
    9.44    /// \ingroup lemon_io
    9.45    ///
    9.46 @@ -526,12 +505,15 @@
    9.47  
    9.48    private:
    9.49  
    9.50 -    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    9.51 -                                                  std::ostream& os);
    9.52 -    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    9.53 -                                                  const std::string& fn);
    9.54 -    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
    9.55 -                                                  const char *fn);
    9.56 +    template <typename DGR>
    9.57 +    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph, 
    9.58 +                                            std::ostream& os);
    9.59 +    template <typename DGR>
    9.60 +    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    9.61 +                                            const std::string& fn);
    9.62 +    template <typename DGR>
    9.63 +    friend DigraphWriter<DGR> digraphWriter(const DGR& digraph,
    9.64 +                                            const char *fn);
    9.65  
    9.66      DigraphWriter(DigraphWriter& other)
    9.67        : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
    9.68 @@ -933,39 +915,49 @@
    9.69      /// @}
    9.70    };
    9.71  
    9.72 +  /// \brief Return a \ref DigraphWriter class
    9.73 +  ///
    9.74 +  /// This function just returns a \ref DigraphWriter class.
    9.75 +  /// \relates DigraphWriter
    9.76 +  template <typename Digraph>
    9.77 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    9.78 +                                       std::ostream& os) {
    9.79 +    DigraphWriter<Digraph> tmp(digraph, os);
    9.80 +    return tmp;
    9.81 +  }
    9.82 +
    9.83 +  /// \brief Return a \ref DigraphWriter class
    9.84 +  ///
    9.85 +  /// This function just returns a \ref DigraphWriter class.
    9.86 +  /// \relates DigraphWriter
    9.87 +  template <typename Digraph>
    9.88 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    9.89 +                                       const std::string& fn) {
    9.90 +    DigraphWriter<Digraph> tmp(digraph, fn);
    9.91 +    return tmp;
    9.92 +  }
    9.93 +
    9.94 +  /// \brief Return a \ref DigraphWriter class
    9.95 +  ///
    9.96 +  /// This function just returns a \ref DigraphWriter class.
    9.97 +  /// \relates DigraphWriter
    9.98 +  template <typename Digraph>
    9.99 +  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
   9.100 +                                       const char* fn) {
   9.101 +    DigraphWriter<Digraph> tmp(digraph, fn);
   9.102 +    return tmp;
   9.103 +  }
   9.104 +
   9.105    template <typename Graph>
   9.106    class GraphWriter;
   9.107  
   9.108 -  /// \brief Return a \ref GraphWriter class
   9.109 -  ///
   9.110 -  /// This function just returns a \ref GraphWriter class.
   9.111 -  /// \relates GraphWriter
   9.112    template <typename Graph>
   9.113    GraphWriter<Graph> graphWriter(const Graph& graph,
   9.114 -                                 std::ostream& os = std::cout) {
   9.115 -    GraphWriter<Graph> tmp(graph, os);
   9.116 -    return tmp;
   9.117 -  }
   9.118 -
   9.119 -  /// \brief Return a \ref GraphWriter class
   9.120 -  ///
   9.121 -  /// This function just returns a \ref GraphWriter class.
   9.122 -  /// \relates GraphWriter
   9.123 +                                 std::ostream& os = std::cout);
   9.124    template <typename Graph>
   9.125 -  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
   9.126 -    GraphWriter<Graph> tmp(graph, fn);
   9.127 -    return tmp;
   9.128 -  }
   9.129 -
   9.130 -  /// \brief Return a \ref GraphWriter class
   9.131 -  ///
   9.132 -  /// This function just returns a \ref GraphWriter class.
   9.133 -  /// \relates GraphWriter
   9.134 +  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
   9.135    template <typename Graph>
   9.136 -  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
   9.137 -    GraphWriter<Graph> tmp(graph, fn);
   9.138 -    return tmp;
   9.139 -  }
   9.140 +  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn);
   9.141  
   9.142    /// \ingroup lemon_io
   9.143    ///
   9.144 @@ -1081,13 +1073,16 @@
   9.145  
   9.146    private:
   9.147  
   9.148 -    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   9.149 -                                            std::ostream& os);
   9.150 -    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   9.151 -                                            const std::string& fn);
   9.152 -    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
   9.153 -                                            const char *fn);
   9.154 -
   9.155 +    template <typename GR>
   9.156 +    friend GraphWriter<GR> graphWriter(const GR& graph,
   9.157 +                                       std::ostream& os);
   9.158 +    template <typename GR>
   9.159 +    friend GraphWriter<GR> graphWriter(const GR& graph,
   9.160 +                                       const std::string& fn);
   9.161 +    template <typename GR>
   9.162 +    friend GraphWriter<GR> graphWriter(const GR& graph,
   9.163 +                                       const char *fn);
   9.164 +    
   9.165      GraphWriter(GraphWriter& other)
   9.166        : _os(other._os), local_os(other.local_os), _graph(other._graph),
   9.167          _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
   9.168 @@ -1534,6 +1529,37 @@
   9.169      /// @}
   9.170    };
   9.171  
   9.172 +  /// \brief Return a \ref GraphWriter class
   9.173 +  ///
   9.174 +  /// This function just returns a \ref GraphWriter class.
   9.175 +  /// \relates GraphWriter
   9.176 +  template <typename Graph>
   9.177 +  GraphWriter<Graph> graphWriter(const Graph& graph,
   9.178 +                                 std::ostream& os) {
   9.179 +    GraphWriter<Graph> tmp(graph, os);
   9.180 +    return tmp;
   9.181 +  }
   9.182 +
   9.183 +  /// \brief Return a \ref GraphWriter class
   9.184 +  ///
   9.185 +  /// This function just returns a \ref GraphWriter class.
   9.186 +  /// \relates GraphWriter
   9.187 +  template <typename Graph>
   9.188 +  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
   9.189 +    GraphWriter<Graph> tmp(graph, fn);
   9.190 +    return tmp;
   9.191 +  }
   9.192 +
   9.193 +  /// \brief Return a \ref GraphWriter class
   9.194 +  ///
   9.195 +  /// This function just returns a \ref GraphWriter class.
   9.196 +  /// \relates GraphWriter
   9.197 +  template <typename Graph>
   9.198 +  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
   9.199 +    GraphWriter<Graph> tmp(graph, fn);
   9.200 +    return tmp;
   9.201 +  }
   9.202 +
   9.203    class SectionWriter;
   9.204  
   9.205    SectionWriter sectionWriter(std::istream& is);
    10.1 --- a/lemon/path.h	Fri Feb 20 18:43:34 2009 +0100
    10.2 +++ b/lemon/path.h	Fri Feb 20 21:37:19 2009 +0000
    10.3 @@ -929,9 +929,8 @@
    10.4      };
    10.5  
    10.6      template <typename Target, typename Source,
    10.7 -              bool buildEnable = BuildTagIndicator<Target>::value,
    10.8 -              bool revEnable = RevPathTagIndicator<Source>::value>
    10.9 -    struct PathCopySelector {
   10.10 +              bool buildEnable = BuildTagIndicator<Target>::value>
   10.11 +    struct PathCopySelectorForward {
   10.12        static void copy(Target& target, const Source& source) {
   10.13          target.clear();
   10.14          for (typename Source::ArcIt it(source); it != INVALID; ++it) {
   10.15 @@ -941,7 +940,16 @@
   10.16      };
   10.17  
   10.18      template <typename Target, typename Source>
   10.19 -    struct PathCopySelector<Target, Source, false, true> {
   10.20 +    struct PathCopySelectorForward<Target, Source, true> {
   10.21 +      static void copy(Target& target, const Source& source) {
   10.22 +        target.clear();
   10.23 +        target.build(source);
   10.24 +      }
   10.25 +    };
   10.26 +
   10.27 +    template <typename Target, typename Source,
   10.28 +              bool buildEnable = BuildTagIndicator<Target>::value>
   10.29 +    struct PathCopySelectorBackward {
   10.30        static void copy(Target& target, const Source& source) {
   10.31          target.clear();
   10.32          for (typename Source::RevArcIt it(source); it != INVALID; ++it) {
   10.33 @@ -951,21 +959,29 @@
   10.34      };
   10.35  
   10.36      template <typename Target, typename Source>
   10.37 -    struct PathCopySelector<Target, Source, true, false> {
   10.38 -      static void copy(Target& target, const Source& source) {
   10.39 -        target.clear();
   10.40 -        target.build(source);
   10.41 -      }
   10.42 -    };
   10.43 -
   10.44 -    template <typename Target, typename Source>
   10.45 -    struct PathCopySelector<Target, Source, true, true> {
   10.46 +    struct PathCopySelectorBackward<Target, Source, true> {
   10.47        static void copy(Target& target, const Source& source) {
   10.48          target.clear();
   10.49          target.buildRev(source);
   10.50        }
   10.51      };
   10.52  
   10.53 +    
   10.54 +    template <typename Target, typename Source,
   10.55 +              bool revEnable = RevPathTagIndicator<Source>::value>
   10.56 +    struct PathCopySelector {
   10.57 +      static void copy(Target& target, const Source& source) {
   10.58 +        PathCopySelectorForward<Target, Source>::copy(target, source);
   10.59 +      }      
   10.60 +    };
   10.61 +
   10.62 +    template <typename Target, typename Source>
   10.63 +    struct PathCopySelector<Target, Source, true> {
   10.64 +      static void copy(Target& target, const Source& source) {
   10.65 +        PathCopySelectorBackward<Target, Source>::copy(target, source);
   10.66 +      }      
   10.67 +    };
   10.68 +
   10.69    }
   10.70  
   10.71  
    11.1 --- a/lemon/random.h	Fri Feb 20 18:43:34 2009 +0100
    11.2 +++ b/lemon/random.h	Fri Feb 20 21:37:19 2009 +0000
    11.3 @@ -344,56 +344,46 @@
    11.4        }
    11.5      };
    11.6  
    11.7 -    template <typename Result, int exp, bool pos = (exp >= 0)>
    11.8 +    template <typename Result, int exp>
    11.9      struct ShiftMultiplier {
   11.10        static const Result multiplier() {
   11.11          Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
   11.12          res *= res;
   11.13 -        if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
   11.14 -        return res;
   11.15 -      }
   11.16 -    };
   11.17 -
   11.18 -    template <typename Result, int exp>
   11.19 -    struct ShiftMultiplier<Result, exp, false> {
   11.20 -      static const Result multiplier() {
   11.21 -        Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
   11.22 -        res *= res;
   11.23          if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
   11.24          return res;
   11.25        }
   11.26      };
   11.27  
   11.28      template <typename Result>
   11.29 -    struct ShiftMultiplier<Result, 0, true> {
   11.30 +    struct ShiftMultiplier<Result, 0> {
   11.31        static const Result multiplier() {
   11.32          return static_cast<Result>(1.0);
   11.33        }
   11.34      };
   11.35  
   11.36      template <typename Result>
   11.37 -    struct ShiftMultiplier<Result, -20, true> {
   11.38 +    struct ShiftMultiplier<Result, 20> {
   11.39        static const Result multiplier() {
   11.40          return static_cast<Result>(1.0/1048576.0);
   11.41        }
   11.42      };
   11.43  
   11.44      template <typename Result>
   11.45 -    struct ShiftMultiplier<Result, -32, true> {
   11.46 +    struct ShiftMultiplier<Result, 32> {
   11.47        static const Result multiplier() {
   11.48 -        return static_cast<Result>(1.0/424967296.0);
   11.49 +        return static_cast<Result>(1.0/4294967296.0);
   11.50        }
   11.51      };
   11.52  
   11.53      template <typename Result>
   11.54 -    struct ShiftMultiplier<Result, -53, true> {
   11.55 +    struct ShiftMultiplier<Result, 53> {
   11.56        static const Result multiplier() {
   11.57          return static_cast<Result>(1.0/9007199254740992.0);
   11.58        }
   11.59      };
   11.60  
   11.61      template <typename Result>
   11.62 -    struct ShiftMultiplier<Result, -64, true> {
   11.63 +    struct ShiftMultiplier<Result, 64> {
   11.64        static const Result multiplier() {
   11.65          return static_cast<Result>(1.0/18446744073709551616.0);
   11.66        }
   11.67 @@ -413,7 +403,7 @@
   11.68        static const int bits = std::numeric_limits<Word>::digits;
   11.69  
   11.70        static Result convert(RandomCore<Word>& rnd) {
   11.71 -        return Shifting<Result, - shift - rest>::
   11.72 +        return Shifting<Result, shift + rest>::
   11.73            shift(static_cast<Result>(rnd() >> (bits - rest)));
   11.74        }
   11.75      };
   11.76 @@ -423,7 +413,7 @@
   11.77        static const int bits = std::numeric_limits<Word>::digits;
   11.78  
   11.79        static Result convert(RandomCore<Word>& rnd) {
   11.80 -        return Shifting<Result, - shift - bits>::
   11.81 +        return Shifting<Result, shift + bits>::
   11.82            shift(static_cast<Result>(rnd())) +
   11.83            RealConversion<Result, Word, rest-bits, shift + bits>::
   11.84            convert(rnd);
    12.1 --- a/lemon/tolerance.h	Fri Feb 20 18:43:34 2009 +0100
    12.2 +++ b/lemon/tolerance.h	Fri Feb 20 21:37:19 2009 +0000
    12.3 @@ -38,17 +38,14 @@
    12.4    ///handle the comparison of numbers that are obtained
    12.5    ///as a result of a probably inexact computation.
    12.6    ///
    12.7 -  ///This is an abstract class, it should be specialized for all
    12.8 -  ///numerical data types. These specialized classes like
    12.9 +  ///The general implementation is suitable only if the data type is exact,
   12.10 +  ///like the integer types, otherwise a specialized version must be
   12.11 +  ///implemented. These specialized classes like
   12.12    ///Tolerance<double> may offer additional tuning parameters.
   12.13    ///
   12.14    ///\sa Tolerance<float>
   12.15    ///\sa Tolerance<double>
   12.16    ///\sa Tolerance<long double>
   12.17 -  ///\sa Tolerance<int>
   12.18 -  ///\sa Tolerance<long long int>
   12.19 -  ///\sa Tolerance<unsigned int>
   12.20 -  ///\sa Tolerance<unsigned long long int>
   12.21  
   12.22    template<class T>
   12.23    class Tolerance
   12.24 @@ -64,20 +61,20 @@
   12.25      ///@{
   12.26  
   12.27      ///Returns \c true if \c a is \e surely strictly less than \c b
   12.28 -    static bool less(Value a,Value b) {return false;}
   12.29 +    static bool less(Value a,Value b) {return a<b;}
   12.30      ///Returns \c true if \c a is \e surely different from \c b
   12.31 -    static bool different(Value a,Value b) {return false;}
   12.32 +    static bool different(Value a,Value b) {return a!=b;}
   12.33      ///Returns \c true if \c a is \e surely positive
   12.34 -    static bool positive(Value a) {return false;}
   12.35 +    static bool positive(Value a) {return static_cast<Value>(0) < a;}
   12.36      ///Returns \c true if \c a is \e surely negative
   12.37 -    static bool negative(Value a) {return false;}
   12.38 +    static bool negative(Value a) {return a < static_cast<Value>(0);}
   12.39      ///Returns \c true if \c a is \e surely non-zero
   12.40 -    static bool nonZero(Value a) {return false;}
   12.41 +    static bool nonZero(Value a) {return a != static_cast<Value>(0);}
   12.42  
   12.43      ///@}
   12.44  
   12.45      ///Returns the zero value.
   12.46 -    static Value zero() {return T();}
   12.47 +    static Value zero() {return static_cast<Value>(0);}
   12.48  
   12.49      //   static bool finite(Value a) {}
   12.50      //   static Value big() {}
   12.51 @@ -238,213 +235,6 @@
   12.52      static Value zero() {return 0;}
   12.53    };
   12.54  
   12.55 -  ///Integer specialization of Tolerance.
   12.56 -
   12.57 -  ///Integer specialization of Tolerance.
   12.58 -  ///\sa Tolerance
   12.59 -  template<>
   12.60 -  class Tolerance<int>
   12.61 -  {
   12.62 -  public:
   12.63 -    ///\e
   12.64 -    typedef int Value;
   12.65 -
   12.66 -    ///\name Comparisons
   12.67 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
   12.68 -
   12.69 -    ///@{
   12.70 -
   12.71 -    ///Returns \c true if \c a is \e surely strictly less than \c b
   12.72 -    static bool less(Value a,Value b) { return a<b;}
   12.73 -    ///Returns \c true if \c a is \e surely different from \c b
   12.74 -    static bool different(Value a,Value b) { return a!=b; }
   12.75 -    ///Returns \c true if \c a is \e surely positive
   12.76 -    static bool positive(Value a) { return 0<a; }
   12.77 -    ///Returns \c true if \c a is \e surely negative
   12.78 -    static bool negative(Value a) { return 0>a; }
   12.79 -    ///Returns \c true if \c a is \e surely non-zero
   12.80 -    static bool nonZero(Value a) { return a!=0; }
   12.81 -
   12.82 -    ///@}
   12.83 -
   12.84 -    ///Returns zero
   12.85 -    static Value zero() {return 0;}
   12.86 -  };
   12.87 -
   12.88 -  ///Unsigned integer specialization of Tolerance.
   12.89 -
   12.90 -  ///Unsigned integer specialization of Tolerance.
   12.91 -  ///\sa Tolerance
   12.92 -  template<>
   12.93 -  class Tolerance<unsigned int>
   12.94 -  {
   12.95 -  public:
   12.96 -    ///\e
   12.97 -    typedef unsigned int Value;
   12.98 -
   12.99 -    ///\name Comparisons
  12.100 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
  12.101 -
  12.102 -    ///@{
  12.103 -
  12.104 -    ///Returns \c true if \c a is \e surely strictly less than \c b
  12.105 -    static bool less(Value a,Value b) { return a<b;}
  12.106 -    ///Returns \c true if \c a is \e surely different from \c b
  12.107 -    static bool different(Value a,Value b) { return a!=b; }
  12.108 -    ///Returns \c true if \c a is \e surely positive
  12.109 -    static bool positive(Value a) { return 0<a; }
  12.110 -    ///Returns \c true if \c a is \e surely negative
  12.111 -    static bool negative(Value) { return false; }
  12.112 -    ///Returns \c true if \c a is \e surely non-zero
  12.113 -    static bool nonZero(Value a) { return a!=0; }
  12.114 -
  12.115 -    ///@}
  12.116 -
  12.117 -    ///Returns zero
  12.118 -    static Value zero() {return 0;}
  12.119 -  };
  12.120 -
  12.121 -
  12.122 -  ///Long integer specialization of Tolerance.
  12.123 -
  12.124 -  ///Long integer specialization of Tolerance.
  12.125 -  ///\sa Tolerance
  12.126 -  template<>
  12.127 -  class Tolerance<long int>
  12.128 -  {
  12.129 -  public:
  12.130 -    ///\e
  12.131 -    typedef long int Value;
  12.132 -
  12.133 -    ///\name Comparisons
  12.134 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
  12.135 -
  12.136 -    ///@{
  12.137 -
  12.138 -    ///Returns \c true if \c a is \e surely strictly less than \c b
  12.139 -    static bool less(Value a,Value b) { return a<b;}
  12.140 -    ///Returns \c true if \c a is \e surely different from \c b
  12.141 -    static bool different(Value a,Value b) { return a!=b; }
  12.142 -    ///Returns \c true if \c a is \e surely positive
  12.143 -    static bool positive(Value a) { return 0<a; }
  12.144 -    ///Returns \c true if \c a is \e surely negative
  12.145 -    static bool negative(Value a) { return 0>a; }
  12.146 -    ///Returns \c true if \c a is \e surely non-zero
  12.147 -    static bool nonZero(Value a) { return a!=0;}
  12.148 -
  12.149 -    ///@}
  12.150 -
  12.151 -    ///Returns zero
  12.152 -    static Value zero() {return 0;}
  12.153 -  };
  12.154 -
  12.155 -  ///Unsigned long integer specialization of Tolerance.
  12.156 -
  12.157 -  ///Unsigned long integer specialization of Tolerance.
  12.158 -  ///\sa Tolerance
  12.159 -  template<>
  12.160 -  class Tolerance<unsigned long int>
  12.161 -  {
  12.162 -  public:
  12.163 -    ///\e
  12.164 -    typedef unsigned long int Value;
  12.165 -
  12.166 -    ///\name Comparisons
  12.167 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
  12.168 -
  12.169 -    ///@{
  12.170 -
  12.171 -    ///Returns \c true if \c a is \e surely strictly less than \c b
  12.172 -    static bool less(Value a,Value b) { return a<b;}
  12.173 -    ///Returns \c true if \c a is \e surely different from \c b
  12.174 -    static bool different(Value a,Value b) { return a!=b; }
  12.175 -    ///Returns \c true if \c a is \e surely positive
  12.176 -    static bool positive(Value a) { return 0<a; }
  12.177 -    ///Returns \c true if \c a is \e surely negative
  12.178 -    static bool negative(Value) { return false; }
  12.179 -    ///Returns \c true if \c a is \e surely non-zero
  12.180 -    static bool nonZero(Value a) { return a!=0;}
  12.181 -
  12.182 -    ///@}
  12.183 -
  12.184 -    ///Returns zero
  12.185 -    static Value zero() {return 0;}
  12.186 -  };
  12.187 -
  12.188 -#if defined __GNUC__ && !defined __STRICT_ANSI__
  12.189 -
  12.190 -  ///Long long integer specialization of Tolerance.
  12.191 -
  12.192 -  ///Long long integer specialization of Tolerance.
  12.193 -  ///\warning This class (more exactly, type <tt>long long</tt>)
  12.194 -  ///is not ansi compatible.
  12.195 -  ///\sa Tolerance
  12.196 -  template<>
  12.197 -  class Tolerance<long long int>
  12.198 -  {
  12.199 -  public:
  12.200 -    ///\e
  12.201 -    typedef long long int Value;
  12.202 -
  12.203 -    ///\name Comparisons
  12.204 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
  12.205 -
  12.206 -    ///@{
  12.207 -
  12.208 -    ///Returns \c true if \c a is \e surely strictly less than \c b
  12.209 -    static bool less(Value a,Value b) { return a<b;}
  12.210 -    ///Returns \c true if \c a is \e surely different from \c b
  12.211 -    static bool different(Value a,Value b) { return a!=b; }
  12.212 -    ///Returns \c true if \c a is \e surely positive
  12.213 -    static bool positive(Value a) { return 0<a; }
  12.214 -    ///Returns \c true if \c a is \e surely negative
  12.215 -    static bool negative(Value a) { return 0>a; }
  12.216 -    ///Returns \c true if \c a is \e surely non-zero
  12.217 -    static bool nonZero(Value a) { return a!=0;}
  12.218 -
  12.219 -    ///@}
  12.220 -
  12.221 -    ///Returns zero
  12.222 -    static Value zero() {return 0;}
  12.223 -  };
  12.224 -
  12.225 -  ///Unsigned long long integer specialization of Tolerance.
  12.226 -
  12.227 -  ///Unsigned long long integer specialization of Tolerance.
  12.228 -  ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
  12.229 -  ///is not ansi compatible.
  12.230 -  ///\sa Tolerance
  12.231 -  template<>
  12.232 -  class Tolerance<unsigned long long int>
  12.233 -  {
  12.234 -  public:
  12.235 -    ///\e
  12.236 -    typedef unsigned long long int Value;
  12.237 -
  12.238 -    ///\name Comparisons
  12.239 -    ///See \ref lemon::Tolerance "Tolerance" for more details.
  12.240 -
  12.241 -    ///@{
  12.242 -
  12.243 -    ///Returns \c true if \c a is \e surely strictly less than \c b
  12.244 -    static bool less(Value a,Value b) { return a<b;}
  12.245 -    ///Returns \c true if \c a is \e surely different from \c b
  12.246 -    static bool different(Value a,Value b) { return a!=b; }
  12.247 -    ///Returns \c true if \c a is \e surely positive
  12.248 -    static bool positive(Value a) { return 0<a; }
  12.249 -    ///Returns \c true if \c a is \e surely negative
  12.250 -    static bool negative(Value) { return false; }
  12.251 -    ///Returns \c true if \c a is \e surely non-zero
  12.252 -    static bool nonZero(Value a) { return a!=0;}
  12.253 -
  12.254 -    ///@}
  12.255 -
  12.256 -    ///Returns zero
  12.257 -    static Value zero() {return 0;}
  12.258 -  };
  12.259 -
  12.260 -#endif
  12.261 -
  12.262    /// @}
  12.263  
  12.264  } //namespace lemon