epoc32/include/stdapis/boost/graph/random_layout.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/graph/random_layout.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,49 @@
     1.4 +// Copyright 2004 The Trustees of Indiana University.
     1.5 +
     1.6 +// Distributed under the Boost Software License, Version 1.0.
     1.7 +// (See accompanying file LICENSE_1_0.txt or copy at
     1.8 +// http://www.boost.org/LICENSE_1_0.txt)
     1.9 +
    1.10 +//  Authors: Douglas Gregor
    1.11 +//           Andrew Lumsdaine
    1.12 +#ifndef BOOST_GRAPH_RANDOM_LAYOUT_HPP
    1.13 +#define BOOST_GRAPH_RANDOM_LAYOUT_HPP
    1.14 +
    1.15 +#include <boost/graph/graph_traits.hpp>
    1.16 +#include <boost/random/uniform_int.hpp>
    1.17 +#include <boost/random/uniform_01.hpp>
    1.18 +#include <boost/random/uniform_real.hpp>
    1.19 +#include <boost/type_traits/is_integral.hpp>
    1.20 +#include <boost/mpl/if.hpp>
    1.21 +
    1.22 +namespace boost {
    1.23 +
    1.24 +template<typename Graph, typename PositionMap, typename Dimension, 
    1.25 +         typename RandomNumberGenerator>
    1.26 +void
    1.27 +random_graph_layout(const Graph& g, PositionMap position_map,
    1.28 +                    Dimension minX, Dimension maxX, 
    1.29 +                    Dimension minY, Dimension maxY,
    1.30 +                    RandomNumberGenerator& gen)
    1.31 +{
    1.32 +  typedef typename mpl::if_<is_integral<Dimension>,
    1.33 +                            uniform_int<Dimension>,
    1.34 +                            uniform_real<Dimension> >::type distrib_t;
    1.35 +  typedef typename mpl::if_<is_integral<Dimension>,
    1.36 +                            RandomNumberGenerator&,
    1.37 +                            uniform_01<RandomNumberGenerator, Dimension> >
    1.38 +    ::type gen_t;
    1.39 +
    1.40 +  gen_t my_gen(gen);
    1.41 +  distrib_t x(minX, maxX);
    1.42 +  distrib_t y(minY, maxY);
    1.43 +  typename graph_traits<Graph>::vertex_iterator vi, vi_end;
    1.44 +  for(tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) {
    1.45 +    position_map[*vi].x = x(my_gen);
    1.46 +    position_map[*vi].y = y(my_gen);
    1.47 +  }
    1.48 +}
    1.49 +
    1.50 +} // end namespace boost
    1.51 +
    1.52 +#endif // BOOST_GRAPH_RANDOM_LAYOUT_HPP