File indexing completed on 2025-06-30 08:16:11
0001
0002
0003
0004
0005
0006
0007
0008
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
0024
0025
0026
0027
0028
0029
0030
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
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 }
0060
0061 #endif