delete_edge.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //=======================================================================
  2. // Copyright 2018
  3. // Authors: Rasmus Ahlberg
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //=======================================================================
  9. #include <iostream>
  10. #include <boost/graph/adjacency_list.hpp>
  11. #include <boost/graph/graph_traits.hpp>
  12. #include <boost/test/minimal.hpp>
  13. int test_main(int argc, char* argv[])
  14. {
  15. typedef int Vertex;
  16. typedef int Edge;
  17. typedef boost::adjacency_list<boost::setS, // Container type for edges
  18. boost::vecS, // Container type for vertices
  19. boost::directedS, // Param for
  20. // directed/undirected/bidirectional
  21. // graph
  22. Vertex, // Type for the vertices
  23. Edge // Type for the edges
  24. > Graph_t;
  25. typedef Graph_t::edge_descriptor EdgeDesc;
  26. typedef Graph_t::vertex_descriptor VertexType;
  27. Graph_t m_graph;
  28. VertexType v1 = boost::add_vertex(m_graph);
  29. VertexType v2 = boost::add_vertex(m_graph);
  30. VertexType v3 = boost::add_vertex(m_graph);
  31. EdgeDesc ed1;
  32. bool inserted1;
  33. boost::tie(ed1, inserted1) = boost::add_edge(v3, v1, m_graph);
  34. BOOST_REQUIRE(inserted1);
  35. static const int EDGE_VAL = 1234;
  36. m_graph[ed1] = EDGE_VAL;
  37. boost::remove_vertex(v2, m_graph);
  38. std::cout << "ed1 " << m_graph[ed1] << std::endl;
  39. BOOST_REQUIRE(m_graph[ed1] == EDGE_VAL);
  40. return 0;
  41. }