//======================================================================= // Copyright 2009 Trustees of Indiana University. // Authors: Michael Hansen, Andrew Lumsdaine // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= #include #include #include #define DIMENSIONS 1 using namespace boost; typedef grid_graph Graph; typedef graph_traits Traits; // Define a simple function to print vertices void print_vertex(Traits::vertex_descriptor vertex_to_print) { std::cout << "(" << vertex_to_print[0] << ")" << std::endl; } int main(int argc, char* argv[]) { // Define a grid_graph boost::array lengths = { { 1 } }; Graph graph(lengths, true); // Start with the first vertex in the graph Traits::vertex_descriptor first_vertex = vertex(0, graph); // Print the previous vertex in dimension 0 (wraps) print_vertex(graph.previous(first_vertex, 0)); // prints "(1)" }