1 // Copyright (C) 2006 The Trustees of Indiana University.
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)
7 // Authors: Douglas Gregor
10 // A test of the distributed compressed sparse row graph type
11 #include <boost/graph/use_mpi.hpp>
12 #include <boost/config.hpp>
13 #include <boost/throw_exception.hpp>
14 #include <boost/serialization/vector.hpp>
15 #include <boost/graph/distributed/compressed_sparse_row_graph.hpp>
16 #include <boost/graph/distributed/mpi_process_group.hpp>
17 #include <boost/graph/distributed/concepts.hpp>
18 #include <boost/graph/erdos_renyi_generator.hpp>
19 #include <boost/random/linear_congruential.hpp>
20 #include <boost/graph/breadth_first_search.hpp>
21 #include <boost/graph/graphviz.hpp>
22 #include <boost/property_map/vector_property_map.hpp>
23 #include <boost/test/minimal.hpp>
25 #ifdef BOOST_NO_EXCEPTIONS
27 boost::throw_exception(std::exception
const& ex
)
29 std::cout
<< ex
.what() << std::endl
;
34 using namespace boost
;
35 using boost::graph::distributed::mpi_process_group
;
39 typedef compressed_sparse_row_graph
<directedS
, no_property
, no_property
, no_property
,
40 distributedS
<mpi_process_group
> >
42 typedef graph_traits
<Digraph
>::vertex_descriptor vertex_descriptor
;
43 typedef graph_traits
<Digraph
>::edge_descriptor edge_descriptor
;
45 function_requires
< GraphConcept
<Digraph
> >();
46 function_requires
< IncidenceGraphConcept
<Digraph
> >();
47 function_requires
< AdjacencyGraphConcept
<Digraph
> >();
49 function_requires
< DistributedVertexListGraphConcept
<Digraph
> >();
50 function_requires
< DistributedEdgeListGraphConcept
<Digraph
> >();
53 ReadablePropertyGraphConcept
<Digraph
, vertex_descriptor
, vertex_global_t
>
56 ReadablePropertyGraphConcept
<Digraph
, vertex_descriptor
, vertex_owner_t
>
59 ReadablePropertyGraphConcept
<Digraph
, vertex_descriptor
, vertex_local_t
>
62 ReadablePropertyGraphConcept
<Digraph
, vertex_descriptor
, vertex_index_t
>
66 ReadablePropertyGraphConcept
<Digraph
, edge_descriptor
, edge_global_t
>
69 // DPG TBD: edge_owner, edge_local property maps
72 ReadablePropertyGraphConcept
<Digraph
, edge_descriptor
, edge_index_t
>
75 // Check default construction
79 int test_main(int argc
, char* argv
[])
81 mpi::environment
env(argc
, argv
);
85 typedef compressed_sparse_row_graph
<directedS
, no_property
, no_property
, no_property
,
86 distributedS
<mpi_process_group
> >
89 // Build an Erdos-Renyi graph to test with
90 typedef sorted_erdos_renyi_iterator
<minstd_rand
, Digraph
> ERIter
;
96 Digraph
g(ERIter(gen
, n
, prob
), ERIter(), n
);
98 breadth_first_search(g
, vertex(0, g
), visitor(bfs_visitor
<>()));
100 std::ofstream
out("dcsr.dot");
101 write_graphviz(out
, g
);