#include #include #include #include #include #include #include using namespace boost; using namespace std; // Type for our graph struct City { int id; int x, y; }; struct Road { int length; }; typedef adjacency_list Graph; typedef graph_traits::edge_descriptor Edge; typedef graph_traits::vertex_descriptor Vertex; void init_graph(Graph &g) { Vertex u1, u2; u1 = add_vertex(g); u2 = add_vertex(g); g[u1].id = 0; g[u1].x = 1; g[u1].y = 3; g[u2].id = 1; g[u2].x = 4; g[u2].y = 1; Edge e1; e1 = (add_edge(u1, u2, g)).first; g[e1].length = 10; } int main() { Graph g_init; init_graph(g_init); vector c; metric_tsp_approx(g_init, weight_map(get(&Road::length, g_init)).vertex_index_map(get(&City::id, g_init)) .make_tsp_tour_visitor(back_inserter(c))); }