#include #include #include #include #include int main () { using namespace boost; // To get compiler errors, comment out the next line; and remove the comment of the next, next line typedef adjacency_list < vecS, vecS, undirectedS, no_property, property < edge_weight_t, int > > Graph; // typedef adjacency_matrix < undirectedS, no_property, property < edge_weight_t, int > > Graph; typedef graph_traits < Graph >::edge_descriptor Edge; typedef graph_traits < Graph >::vertex_descriptor Vertex; typedef std::pair E; typedef int weight_t; typedef property EProperty; const int num_nodes = 5; E edges[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) }; int weights[] = { 1, 1, 2, 7, 3, 1, 1 }; std::size_t num_edges = sizeof(edges) / sizeof(E); Graph g1 (num_nodes); boost::property_map::type vertex_id = get(vertex_index, g1); for (unsigned int i = 0; i < num_edges; i++) { add_edge (edges[i].first, edges[i].second, weights[i], g1); } print_graph (g1); Graph g2 (&edges[0], edges + num_nodes, weights, num_nodes); print_graph (g2); return EXIT_SUCCESS; }