]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph_parallel/test/distributed_st_connected_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / graph_parallel / test / distributed_st_connected_test.cpp
1 // Copyright (C) 2004-2006 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Authors: Nick Edmonds
8 // Andrew Lumsdaine
9
10 #include <boost/graph/use_mpi.hpp>
11 #include <boost/config.hpp>
12 #include <boost/throw_exception.hpp>
13 #include <boost/graph/distributed/adjacency_list.hpp>
14 #include <boost/graph/random.hpp>
15 #include <boost/property_map/parallel/distributed_property_map.hpp>
16 #include <boost/graph/distributed/mpi_process_group.hpp>
17 #include <boost/graph/distributed/st_connected.hpp>
18 #include <boost/graph/parallel/distribution.hpp>
19 #include <boost/graph/small_world_generator.hpp>
20 #include <iostream>
21 #include <cstdlib>
22 #include <iomanip>
23 #include <boost/random.hpp>
24 #include <boost/test/minimal.hpp>
25
26 #ifdef BOOST_NO_EXCEPTIONS
27 void
28 boost::throw_exception(std::exception const& ex)
29 {
30 std::cout << ex.what() << std::endl;
31 abort();
32 }
33 #endif
34
35 using namespace boost;
36 using boost::graph::distributed::mpi_process_group;
37
38 // Set up the vertex names
39 enum vertex_id_t { u, v, w, x, y, z, N };
40 char vertex_names[] = { 'u', 'v', 'w', 'x', 'y', 'z' };
41
42 void
43 test_distributed_st_connected() {
44
45 typedef adjacency_list<listS,
46 distributedS<mpi_process_group, vecS>,
47 undirectedS,
48 // Vertex properties
49 property<vertex_color_t, default_color_type> >
50 Graph;
51
52 // Specify the edges in the graph
53 {
54 typedef std::pair<int, int> E;
55 E edge_array[] = { E(u, u), E(u, v), E(u, w), E(v, w), E(x, y),
56 E(x, z), E(z, y), E(z, z) };
57 Graph g(edge_array, edge_array + sizeof(edge_array) / sizeof(E), N);
58
59 bool connected = st_connected(g, vertex(u, g), vertex(z, g),
60 get(vertex_color, g), get(vertex_owner, g));
61
62 assert(!connected);
63 }
64
65 {
66 typedef std::pair<int, int> E;
67 E edge_array[] = { E(u, v), E(u, w), E(u, x), E(x, v), E(y, x),
68 E(v, y), E(w, y), E(w, z), E(z, z) };
69 Graph g(edge_array, edge_array + sizeof(edge_array) / sizeof(E), N);
70
71 bool connected = st_connected(g, vertex(u, g), vertex(z, g),
72 get(vertex_color, g), get(vertex_owner, g));
73
74 assert(connected);
75 }
76
77
78 }
79
80 int test_main(int argc, char* argv[])
81 {
82 mpi::environment env(argc, argv);
83 test_distributed_st_connected();
84 return 0;
85 }