]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Copyright (C) 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: Brian Barrett | |
8 | // Nick Edmonds | |
9 | // Andrew Lumsdaine | |
10 | ||
11 | #include <boost/graph/use_mpi.hpp> | |
12 | #include <boost/config.hpp> | |
13 | #include <boost/throw_exception.hpp> | |
14 | #include <boost/graph/distributed/adjacency_list.hpp> | |
15 | #include <boost/property_map/parallel/distributed_property_map.hpp> | |
16 | #include <boost/graph/distributed/mpi_process_group.hpp> | |
17 | #include <boost/graph/dimacs.hpp> | |
18 | #include <boost/graph/graphviz.hpp> | |
1e59de90 | 19 | #include <boost/core/lightweight_test.hpp> |
7c673cae FG |
20 | |
21 | #include <iostream> | |
22 | #include <cstdlib> | |
23 | #include <iomanip> | |
24 | #include <fstream> | |
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 namespace boost::graph; | |
37 | using boost::graph::distributed::mpi_process_group; | |
38 | ||
39 | typedef double time_type; | |
40 | ||
41 | inline time_type get_time() | |
42 | { | |
43 | return MPI_Wtime(); | |
44 | } | |
45 | ||
46 | std::string print_time(time_type t) | |
47 | { | |
48 | std::ostringstream out; | |
49 | out << std::setiosflags(std::ios::fixed) << std::setprecision(2) << t; | |
50 | return out.str(); | |
51 | } | |
52 | ||
53 | void | |
54 | test_dimacs_reader(const char *filename) | |
55 | { | |
56 | mpi_process_group pg; | |
57 | ||
58 | typedef adjacency_list<vecS, | |
59 | distributedS<mpi_process_group, vecS>, | |
60 | undirectedS> Graph; | |
61 | ||
62 | std::ifstream file(filename); | |
63 | dimacs_basic_reader reader = dimacs_basic_reader(file, false); | |
64 | dimacs_basic_reader end; | |
65 | boost::parallel::variant_distribution<mpi_process_group> distrib = | |
66 | boost::parallel::block(pg, reader.n_vertices()); | |
67 | ||
68 | Graph g(dimacs_edge_iterator<dimacs_basic_reader>(reader), | |
69 | dimacs_edge_iterator<dimacs_basic_reader>(end), | |
70 | reader.n_vertices(), pg, distrib);; | |
71 | ||
72 | // write_graphviz("reader.dot", g); | |
73 | } | |
74 | ||
75 | int | |
1e59de90 | 76 | main(int argc, char* argv[]) |
7c673cae FG |
77 | { |
78 | mpi::environment env(argc, argv); | |
79 | ||
80 | if (argc == 2) { | |
81 | test_dimacs_reader(argv[1]); | |
82 | } | |
83 | ||
1e59de90 | 84 | return boost::report_errors(); |
7c673cae | 85 | } |