1 | // (C) Copyright Jeremy Siek 2004 |
---|
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 | #include <iostream> |
---|
7 | #include <boost/graph/adjacency_list.hpp> |
---|
8 | #include <boost/cstdlib.hpp> |
---|
9 | #include <boost/test/test_tools.hpp> |
---|
10 | |
---|
11 | struct edge_prop { |
---|
12 | int weight; |
---|
13 | }; |
---|
14 | |
---|
15 | int |
---|
16 | main() |
---|
17 | { |
---|
18 | { |
---|
19 | typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, |
---|
20 | boost::no_property, edge_prop> graph; |
---|
21 | typedef boost::graph_traits<graph>::edge_descriptor edge; |
---|
22 | |
---|
23 | graph g(2); |
---|
24 | |
---|
25 | edge_prop p = { 42 }; |
---|
26 | edge e; bool b; |
---|
27 | tie(e, b) = add_edge(0, 1, p, g); |
---|
28 | assert( num_edges(g) == 1 ); |
---|
29 | assert( g[e].weight == 42 ); |
---|
30 | remove_edge(e, g); |
---|
31 | assert( num_edges(g) == 0 ); |
---|
32 | } |
---|
33 | { |
---|
34 | typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS> graph; |
---|
35 | typedef boost::graph_traits<graph>::edge_descriptor edge; |
---|
36 | |
---|
37 | graph g(2); |
---|
38 | |
---|
39 | edge e; bool b; |
---|
40 | tie(e, b) = add_edge(0, 1, g); |
---|
41 | assert( num_edges(g) == 1 ); |
---|
42 | remove_edge(e, g); |
---|
43 | assert( num_edges(g) == 0 ); |
---|
44 | } |
---|
45 | return boost::exit_success; |
---|
46 | } |
---|