Template Parameters

Dimensions - Number of dimensions in the graph, must be greater than 2

VertexIndex - Type used for vertex indices, defaults to std::size_t

EdgeIndex - Type used for edge indices, defaults to the same type as VertexIndex

Creating a Grid Graph

The constructor to grid_graph has several overloads to aid in configuring each dimension:

// Defines a grid_graph that does not wrap.grid_graph<...>(boost:array<VertexIndex, Dimensions> dimension_lengths);
// Defines a grid_graph where all dimensions are either wrapped or unwrapped.grid_graph<...>(boost:array<VertexIndex, Dimensions> dimension_lengths,
bool wrap_all_dimensions);
// Defines a grid_graph where the wrapping for each dimension is specified individually.grid_graph<...>(boost:array<VertexIndex, Dimensions> dimension_lengths,
boost:array<bool, Dimensions> wrap_dimension);

Member Functions

There are several grid_graph specific member functions available:

typedefgrid_graph<...> Graph;
typedefgraph_traits<Graph> Traits;
// Returns the number of dimensionsstd::size_t dimensions();
// Returns the length of a dimensionTraits::vertices_size_type length(std::size_t dimension);
// Returns true if the dimension wraps, false if notbool wrapped(std::size_t dimension);
// Returns the "next" vertex in a dimension at a given distance. If the dimension
// is unwrapped, next will stop at the last vertex in the dimension.
Traits::vertex_descriptor next(Traits::vertex_descriptor vertex,
std::size_t dimension,
Traits::vertices_size_type distance = 1);
// Returns the "previous" vertex in a dimension at a given distance. If the
// dimension is unwrapped, previous will stop at the beginning vertex in the dimension.
Traits::vertex_descriptor previous(Traits::vertex_descriptor vertex,
std::size_t dimension,
Traits::vertices_size_type distance = 1);