File indexing completed on 2025-01-18 09:37:24
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/static_assert.hpp>
0018
0019 namespace boost
0020 {
0021
0022
0023
0024
0025
0026
0027
0028
0029
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
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 }
0059
0060 #endif