bidir_remove_edge.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // (C) Copyright Jeremy Siek 2004
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <iostream>
  6. #include <boost/graph/adjacency_list.hpp>
  7. #include <boost/cstdlib.hpp>
  8. #include <boost/detail/lightweight_test.hpp>
  9. struct edge_prop {
  10. int weight;
  11. };
  12. int
  13. main(int, char*[])
  14. {
  15. {
  16. typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
  17. boost::no_property, edge_prop> graph;
  18. typedef boost::graph_traits<graph>::edge_descriptor edge;
  19. graph g(2);
  20. edge_prop p = { 42 };
  21. edge e; bool b;
  22. boost::tie(e, b) = add_edge(0, 1, p, g);
  23. BOOST_TEST( num_edges(g) == 1 );
  24. BOOST_TEST( g[e].weight == 42 );
  25. remove_edge(e, g);
  26. BOOST_TEST( num_edges(g) == 0 );
  27. }
  28. {
  29. typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> graph;
  30. typedef boost::graph_traits<graph>::edge_descriptor edge;
  31. graph g(2);
  32. edge e; bool b;
  33. boost::tie(e, b) = add_edge(0, 1, g);
  34. BOOST_TEST( num_edges(g) == 1 );
  35. remove_edge(e, g);
  36. BOOST_TEST( num_edges(g) == 0 );
  37. }
  38. return boost::report_errors();
  39. }