distributed_st_connected_test.cpp 2.5 KB

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