1 //=======================================================================
3 // Authors: Rasmus Ahlberg
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 //=======================================================================
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/graph_traits.hpp>
15 #include <boost/core/lightweight_test.hpp>
17 int main(int argc
, char* argv
[])
22 typedef boost::adjacency_list
< boost::setS
, // Container type for edges
23 boost::vecS
, // Container type for vertices
24 boost::directedS
, // Param for
25 // directed/undirected/bidirectional
27 Vertex
, // Type for the vertices
28 Edge
// Type for the edges
32 typedef Graph_t::edge_descriptor EdgeDesc
;
33 typedef Graph_t::vertex_descriptor VertexType
;
37 VertexType v1
= boost::add_vertex(m_graph
);
38 VertexType v2
= boost::add_vertex(m_graph
);
39 VertexType v3
= boost::add_vertex(m_graph
);
44 boost::tie(ed1
, inserted1
) = boost::add_edge(v3
, v1
, m_graph
);
46 BOOST_TEST(inserted1
);
48 static const int EDGE_VAL
= 1234;
50 m_graph
[ed1
] = EDGE_VAL
;
52 boost::remove_vertex(v2
, m_graph
);
54 std::cout
<< "ed1 " << m_graph
[ed1
] << std::endl
;
56 BOOST_TEST(m_graph
[ed1
] == EDGE_VAL
);
58 // https://github.com/boostorg/graph/issues/268
61 boost::adjacency_list
<boost::setS
, boost::vecS
, boost::undirectedS
> g
;
62 boost::add_edge(2, 0, g
);
63 boost::remove_vertex(1, g
);
64 BOOST_TEST(num_vertices(g
) == 2);
65 BOOST_TEST(num_edges(g
) == 1);
69 boost::adjacency_list
<boost::setS
, boost::vecS
, boost::directedS
> g
;
70 boost::add_edge(2, 0, g
);
71 boost::remove_vertex(1, g
);
72 BOOST_TEST(num_vertices(g
) == 2);
73 BOOST_TEST(num_edges(g
) == 1);
76 return boost::report_errors();