epoc32/include/stdapis/boost/graph/circle_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/circle_layout.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,55 @@
     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_CIRCLE_LAYOUT_HPP
    1.13 +#define BOOST_GRAPH_CIRCLE_LAYOUT_HPP
    1.14 +#include <cmath>
    1.15 +#include <utility>
    1.16 +#include <boost/graph/graph_traits.hpp>
    1.17 +
    1.18 +namespace boost {
    1.19 +  /** 
    1.20 +   * \brief Layout the graph with the vertices at the points of a regular
    1.21 +   * n-polygon. 
    1.22 +   *
    1.23 +   * The distance from the center of the polygon to each point is
    1.24 +   * determined by the @p radius parameter. The @p position parameter
    1.25 +   * must be an Lvalue Property Map whose value type is a class type
    1.26 +   * containing @c x and @c y members that will be set to the @c x and
    1.27 +   * @c y coordinates.
    1.28 +   */
    1.29 +  template<typename VertexListGraph, typename PositionMap, typename Radius>
    1.30 +  void 
    1.31 +  circle_graph_layout(const VertexListGraph& g, PositionMap position,
    1.32 +                      Radius radius)
    1.33 +  {
    1.34 +    const double pi = 3.14159;
    1.35 +
    1.36 +#ifndef BOOST_NO_STDC_NAMESPACE
    1.37 +    using std::sin;
    1.38 +    using std::cos;
    1.39 +#endif // BOOST_NO_STDC_NAMESPACE
    1.40 +
    1.41 +    typedef typename graph_traits<VertexListGraph>::vertices_size_type 
    1.42 +      vertices_size_type;
    1.43 +
    1.44 +    vertices_size_type n = num_vertices(g);
    1.45 +    
    1.46 +    typedef typename graph_traits<VertexListGraph>::vertex_iterator 
    1.47 +      vertex_iterator;
    1.48 +
    1.49 +    vertices_size_type i = 0;
    1.50 +    for(std::pair<vertex_iterator, vertex_iterator> v = vertices(g); 
    1.51 +        v.first != v.second; ++v.first, ++i) {
    1.52 +      position[*v.first].x = radius * cos(i * 2 * pi / n);
    1.53 +      position[*v.first].y = radius * sin(i * 2 * pi / n);
    1.54 +    }
    1.55 +  }
    1.56 +} // end namespace boost
    1.57 +
    1.58 +#endif // BOOST_GRAPH_CIRCLE_LAYOUT_HPP