sl@0: // Copyright 2004 The Trustees of Indiana University. sl@0: sl@0: // Distributed under the Boost Software License, Version 1.0. sl@0: // (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // Authors: Douglas Gregor sl@0: // Andrew Lumsdaine sl@0: #ifndef BOOST_GRAPH_CIRCLE_LAYOUT_HPP sl@0: #define BOOST_GRAPH_CIRCLE_LAYOUT_HPP sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: namespace boost { sl@0: /** sl@0: * \brief Layout the graph with the vertices at the points of a regular sl@0: * n-polygon. sl@0: * sl@0: * The distance from the center of the polygon to each point is sl@0: * determined by the @p radius parameter. The @p position parameter sl@0: * must be an Lvalue Property Map whose value type is a class type sl@0: * containing @c x and @c y members that will be set to the @c x and sl@0: * @c y coordinates. sl@0: */ sl@0: template sl@0: void sl@0: circle_graph_layout(const VertexListGraph& g, PositionMap position, sl@0: Radius radius) sl@0: { sl@0: const double pi = 3.14159; sl@0: sl@0: #ifndef BOOST_NO_STDC_NAMESPACE sl@0: using std::sin; sl@0: using std::cos; sl@0: #endif // BOOST_NO_STDC_NAMESPACE sl@0: sl@0: typedef typename graph_traits::vertices_size_type sl@0: vertices_size_type; sl@0: sl@0: vertices_size_type n = num_vertices(g); sl@0: sl@0: typedef typename graph_traits::vertex_iterator sl@0: vertex_iterator; sl@0: sl@0: vertices_size_type i = 0; sl@0: for(std::pair v = vertices(g); sl@0: v.first != v.second; ++v.first, ++i) { sl@0: position[*v.first].x = radius * cos(i * 2 * pi / n); sl@0: position[*v.first].y = radius * sin(i * 2 * pi / n); sl@0: } sl@0: } sl@0: } // end namespace boost sl@0: sl@0: #endif // BOOST_GRAPH_CIRCLE_LAYOUT_HPP