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.

Layout

Compute 2D or 3D coordinates for vertices so the graph can be drawn. Layout algorithms do not change the graph structure; they only produce positions.

Algorithm When to use

Random Layout

Starting point. Assigns random positions. Often used to seed a force-directed layout.

Circle Layout

Places vertices evenly on a circle. Good for small graphs or ring topologies.

Kamada-Kawai

Spring model based on graph-theoretic distances. Produces aesthetically pleasing layouts for small to medium graphs (< ~1000 vertices).

Fruchterman-Reingold

Force-directed. Scales better than Kamada-Kawai. Good for medium graphs.

Gursoy-Atun

Topology-based layout using self-organizing maps. Works on arbitrary topologies (sphere, torus, etc.).

For most graphs, start with a random layout and then run Fruchterman-Reingold or Kamada-Kawai. Kamada-Kawai produces better results but is slower; Fruchterman-Reingold is faster and handles larger graphs.

All layout algorithms write positions into a property map. The topology (rectangle, circle, sphere, heart, etc.) is specified via a topology object; see Topologies for Graph Drawing for the catalog of built-in types (square_topology, cube_topology, ball_topology, sphere_topology, heart_topology, …) and the concept a custom topology must model.