Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:24

0001 // Copyright 2004 The Trustees of Indiana University.
0002 
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Authors: Douglas Gregor
0008 //           Andrew Lumsdaine
0009 #ifndef BOOST_GRAPH_CIRCLE_LAYOUT_HPP
0010 #define BOOST_GRAPH_CIRCLE_LAYOUT_HPP
0011 #include <boost/config/no_tr1/cmath.hpp>
0012 #include <boost/math/constants/constants.hpp>
0013 #include <utility>
0014 #include <boost/graph/graph_traits.hpp>
0015 #include <boost/graph/iteration_macros.hpp>
0016 #include <boost/graph/topology.hpp>
0017 #include <boost/static_assert.hpp>
0018 
0019 namespace boost
0020 {
0021 /**
0022  * \brief Layout the graph with the vertices at the points of a regular
0023  * n-polygon.
0024  *
0025  * The distance from the center of the polygon to each point is
0026  * determined by the @p radius parameter. The @p position parameter
0027  * must be an Lvalue Property Map whose value type is a class type
0028  * containing @c x and @c y members that will be set to the @c x and
0029  * @c y coordinates.
0030  */
0031 template < typename VertexListGraph, typename PositionMap, typename Radius >
0032 void circle_graph_layout(
0033     const VertexListGraph& g, PositionMap position, Radius radius)
0034 {
0035     BOOST_STATIC_ASSERT(
0036         property_traits< PositionMap >::value_type::dimensions >= 2);
0037     const double pi = boost::math::constants::pi< double >();
0038 
0039 #ifndef BOOST_NO_STDC_NAMESPACE
0040     using std::cos;
0041     using std::sin;
0042 #endif // BOOST_NO_STDC_NAMESPACE
0043 
0044     typedef typename graph_traits< VertexListGraph >::vertices_size_type
0045         vertices_size_type;
0046 
0047     vertices_size_type n = num_vertices(g);
0048 
0049     vertices_size_type i = 0;
0050     double two_pi_over_n = 2. * pi / n;
0051     BGL_FORALL_VERTICES_T(v, g, VertexListGraph)
0052     {
0053         position[v][0] = radius * cos(i * two_pi_over_n);
0054         position[v][1] = radius * sin(i * two_pi_over_n);
0055         ++i;
0056     }
0057 }
0058 } // end namespace boost
0059 
0060 #endif // BOOST_GRAPH_CIRCLE_LAYOUT_HPP