Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:16:11

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/property_map/property_map.hpp>
0018 #include <boost/static_assert.hpp>
0019 
0020 namespace boost
0021 {
0022 /**
0023  * \brief Layout the graph with the vertices at the points of a regular
0024  * n-polygon.
0025  *
0026  * The distance from the center of the polygon to each point is
0027  * determined by the @p radius parameter. The @p position parameter
0028  * must be an Lvalue Property Map whose value type is a class type
0029  * containing @c x and @c y members that will be set to the @c x and
0030  * @c y coordinates.
0031  */
0032 template < typename VertexListGraph, typename PositionMap, typename Radius >
0033 void circle_graph_layout(
0034     const VertexListGraph& g, PositionMap position, Radius radius)
0035 {
0036     BOOST_STATIC_ASSERT(
0037         property_traits< PositionMap >::value_type::dimensions >= 2);
0038     const double pi = boost::math::constants::pi< double >();
0039 
0040 #ifndef BOOST_NO_STDC_NAMESPACE
0041     using std::cos;
0042     using std::sin;
0043 #endif // BOOST_NO_STDC_NAMESPACE
0044 
0045     typedef typename graph_traits< VertexListGraph >::vertices_size_type
0046         vertices_size_type;
0047 
0048     vertices_size_type n = num_vertices(g);
0049 
0050     vertices_size_type i = 0;
0051     double two_pi_over_n = 2. * pi / n;
0052     BGL_FORALL_VERTICES_T(v, g, VertexListGraph)
0053     {
0054         position[v][0] = radius * cos(i * two_pi_over_n);
0055         position[v][1] = radius * sin(i * two_pi_over_n);
0056         ++i;
0057     }
0058 }
0059 } // end namespace boost
0060 
0061 #endif // BOOST_GRAPH_CIRCLE_LAYOUT_HPP