diff --git a/Graph/newboost.cxx b/Graph/newboost.cxx new file mode 100644 index 0000000..9535513 --- /dev/null +++ b/Graph/newboost.cxx @@ -0,0 +1,35 @@ +#include +#include + +typedef boost::property EdgeWeightProperty; +typedef boost::adjacency_list DirectedGraph; +typedef boost::graph_traits::edge_iterator edge_iterator; + +int main() + +{ + DirectedGraph g; + + boost::add_edge (0, 1, 8, g); + boost::add_edge (0, 3, 18, g); + boost::add_edge (1, 2, 20, g); + boost::add_edge (2, 3, 2, g); + boost::add_edge (3, 1, 1, g); + boost::add_edge (1, 3, 7, g); + boost::add_edge (1, 4, 1, g); + boost::add_edge (4, 5, 6, g); + boost::add_edge (2, 5, 7, g); + + std::pair ei = edges(g); + + std::cout << "Number of edges = " << num_edges(g) << "\n"; + std::cout << "Edge list:\n"; + + std::copy( ei.first, ei.second, + std::ostream_iterator::edge_descriptor>{ + std::cout, "\n"}); + + std::cout << std::endl; + + return 0; + }