1 //=======================================================================
2 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
3 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
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 <boost/config.hpp>
11 #include <iostream>
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/graph_utility.hpp>
14
15 /*
16 Sample output:
17
18 original graph:
19 0 --> 3 2 3
20 1 --> 3
21 2 --> 0
22 3 --> 2
23
24 removing edges (0,3)
25 0 --> 2
26 1 --> 3
27 2 --> 0
28 3 --> 2
29 removing edge (0,2) and (3, 2)
30 0 -->
31 1 --> 3
32 2 --> 0
33 3 -->
34
35 */
36
37 using namespace boost;
38
39 typedef adjacency_list< vecS, vecS, directedS > Graph;
40
main()41 int main()
42 {
43 typedef std::pair< std::size_t, std::size_t > Edge;
44 Edge edges[6] = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3),
45 Edge(2, 0), Edge(3, 2) };
46
47 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
48 // VC++ can't handle iterator constructor
49 Graph g(4);
50 for (std::size_t j = 0; j < 6; ++j)
51 add_edge(edges[j].first, edges[j].second, g);
52 #else
53 Graph g(edges, edges + 6, 4);
54 #endif
55
56 std::cout << "original graph:" << std::endl;
57 print_graph(g, get(vertex_index, g));
58 std::cout << std::endl;
59
60 std::cout << "removing edges (0,3)" << std::endl;
61 remove_out_edge_if(vertex(0, g), incident_to(vertex(3, g), g), g);
62 print_graph(g, get(vertex_index, g));
63
64 std::cout << "removing edge (0,2) and (3, 2)" << std::endl;
65 remove_edge_if(incident_to(vertex(2, g), g), g);
66 print_graph(g, get(vertex_index, g));
67
68 return 0;
69 }
70