]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/delete_edge.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / graph / test / delete_edge.cpp
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
10 #include <iostream>
11
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/graph_traits.hpp>
14
15 #include <boost/core/lightweight_test.hpp>
16
17 int main(int argc, char* argv[])
18 {
19 typedef int Vertex;
20 typedef int Edge;
21
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
26 // graph
27 Vertex, // Type for the vertices
28 Edge // Type for the edges
29 >
30 Graph_t;
31
32 typedef Graph_t::edge_descriptor EdgeDesc;
33 typedef Graph_t::vertex_descriptor VertexType;
34
35 Graph_t m_graph;
36
37 VertexType v1 = boost::add_vertex(m_graph);
38 VertexType v2 = boost::add_vertex(m_graph);
39 VertexType v3 = boost::add_vertex(m_graph);
40
41 EdgeDesc ed1;
42 bool inserted1;
43
44 boost::tie(ed1, inserted1) = boost::add_edge(v3, v1, m_graph);
45
46 BOOST_TEST(inserted1);
47
48 static const int EDGE_VAL = 1234;
49
50 m_graph[ed1] = EDGE_VAL;
51
52 boost::remove_vertex(v2, m_graph);
53
54 std::cout << "ed1 " << m_graph[ed1] << std::endl;
55
56 BOOST_TEST(m_graph[ed1] == EDGE_VAL);
57
58 // https://github.com/boostorg/graph/issues/268
59 // 1. Undirected:
60 {
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);
66 }
67 // 2. Directed:
68 {
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);
74 }
75
76 return boost::report_errors();
77 }