#include #include #include #include using namespace std; using namespace boost; class host { /* ... */ }; class connection { /* ... */ }; class platform : public adjacency_list< listS, multisetS, bidirectionalS, host, connection > { /* ... */ }; int main(int argc, char* argv[]) { platform g; cout << "Generate vertices:\n"; host hosts[3]; add_vertex(hosts[0], g); add_vertex(hosts[1], g); add_vertex(hosts[2], g); cout << "All vertices:\n"; platform::vertex_iterator u_it, u_end; for(tie(u_it, u_end) = vertices(g); u_it != u_end; ++u_it) { cout << " " << *u_it; } cout << endl; cout << "Generate edges:\n"; connection connections[2]; add_edge(vertex(1, g), vertex(2, g), connections[0], g); add_edge(vertex(1, g), vertex(0, g), connections[1], g); cout << "All edges:\n"; platform::edge_iterator e_it, e_end; for(tie(e_it, e_end) = edges(g); e_it != e_end; ++e_it) { cout << " " << *e_it; } cout << endl; cout << "Out edges 0->1:\n"; platform::out_edge_iterator o_it, o_end; for(tie(o_it, o_end) = edge_range(vertex(0, g), vertex(1, g), g); o_it != o_end; ++o_it) { cout << " " << *o_it; } cout << endl; cout << "Out edges 1->0:\n"; for(tie(o_it, o_end) = edge_range(vertex(1, g), vertex(0, g), g); o_it != o_end; ++o_it) { cout << " " << *o_it; } cout << endl; return 0; } /* example output: **************************************************** Generate vertices: All vertices: 0x804f3d0 0x804f3e8 0x804f400 Generate edges: All edges: (0x804f3e8,0x804f400) (0x804f3e8,0x804f3d0) Out edges 0->1: Out edges 1->0: (0x804f3e8,0x804f400) (0x804f3e8,0x804f3d0) */