]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/bidir_vec_remove_edge.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph / test / bidir_vec_remove_edge.cpp
1 // (C) Copyright 2004 Douglas Gregor and Jeremy Siek
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
6 // NOTE: This test illustrates a longstanding bug in the
7 // adjacency_list class template. We do not test it because it will
8 // cause problems until we have time to fix the bug. Annoying? Yes.
9
10 #include <iostream>
11 #include <boost/graph/adjacency_list.hpp>
12 #include <boost/test/minimal.hpp>
13
14 struct edge_prop {
15 int weight;
16 };
17
18 int
19 test_main(int, char*[])
20 {
21 {
22 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS,
23 boost::no_property, edge_prop, boost::no_property, boost::vecS> graph;
24 typedef boost::graph_traits<graph>::edge_descriptor edge;
25
26 graph g(2);
27
28 edge_prop p1 = { 42 };
29 edge_prop p2 = { 17 };
30 add_edge(0, 1, p1, g);
31 add_edge(1, 0, p2, g);
32
33 edge e1 = boost::edge(0, 1, g).first;
34 edge e2 = boost::edge(1, 0, g).first;
35 BOOST_CHECK( num_edges(g) == 2 );
36 BOOST_CHECK( g[e1].weight == 42 );
37 BOOST_CHECK( g[e2].weight == 17 );
38 remove_edge(e1, g);
39 BOOST_CHECK( num_edges(g) == 1 );
40
41 // e2 has been invalidated, so grab it again
42 bool b2;
43 boost::tie(e2, b2) = boost::edge(1, 0, g);
44 BOOST_CHECK( b2 );
45 BOOST_CHECK( g[e2].weight == 17 );
46
47 /* Now remove the other edge. Here, the fact that
48 * stored_ra_edge_iterator keeps an index but does not update it
49 * when edges are removed. So, this will be incorrect but the
50 * error may not always show up (use an STL debug mode to see the
51 * error for sure.)
52 */
53 remove_edge(e2, g);
54
55 }
56 return boost::exit_success;
57 }