• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
main(int argc,char * argv[])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     return boost::report_errors();
59 }
60