This documentation is being rewritten. If something looks off, please cross-check with the Boost 1.91.0 Boost.Graph docs and open an issue.

circle_graph_layout

Lays out the graph with the vertices at the points of a regular n-polygon.

Defined in: <boost/graph/circle_layout.hpp>

Example

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/circle_layout.hpp>
#include <boost/graph/topology.hpp>
#include <iostream>
#include <vector>

using namespace boost;
using Point = convex_topology<2>::point_type;
using Graph = adjacency_list<vecS, vecS, undirectedS>;

int main() {
    Graph g(5);
    add_edge(0, 1, g); add_edge(1, 2, g);
    add_edge(2, 3, g); add_edge(3, 4, g); add_edge(4, 0, g);

    std::vector<Point> positions(num_vertices(g));
    auto pos_map = make_iterator_property_map(
        positions.begin(), get(vertex_index, g));

    circle_graph_layout(g, pos_map, 50.0);

    for (auto v : make_iterator_range(vertices(g)))
        std::cout << "vertex " << v << ": ("
                  << positions[v][0] << ", " << positions[v][1] << ")\n";
}
vertex 0: (50, 0)
vertex 1: (15.4508, 47.5528)
vertex 2: (-40.4508, 29.3893)
vertex 3: (-40.4508, -29.3893)
vertex 4: (15.4508, -47.5528)

Positional version

template<typename VertexListGraph, typename PositionMap, typename Radius>
void circle_graph_layout(
    const VertexListGraph& g,
    PositionMap position,
    Radius radius);
Direction Parameter Description

IN

const VertexListGraph& g

The graph object on which the algorithm will be applied. The type VertexListGraph must be a model of Vertex List Graph.

OUT

PositionMap position

This property map is used to store the position of each vertex. The type PositionMap must be a model of Writable Property Map, with the graph’s vertex descriptor type as its key type. The value type of this property map should be assignable from the type Radius.

IN

Radius radius

This is the radius of the circle on which points will be laid out. It must be compatible with double.

Description

The distance from the center of the polygon to each point is determined by the radius parameter. The position parameter must be an Lvalue Property Map whose value type is a class type containing x and y members that will be set to the x and y coordinates.