Chris@16
|
1 // Copyright (C) 2004-2006 The Trustees of Indiana University.
|
Chris@16
|
2
|
Chris@16
|
3 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 // Authors: Douglas Gregor
|
Chris@16
|
8 // Andrew Lumsdaine
|
Chris@16
|
9
|
Chris@16
|
10 //
|
Chris@16
|
11 // Distributed graph concepts and helpers
|
Chris@16
|
12 //
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP
|
Chris@16
|
15 #define BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP
|
Chris@16
|
16
|
Chris@16
|
17 #ifndef BOOST_GRAPH_USE_MPI
|
Chris@16
|
18 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
|
Chris@16
|
19 #endif
|
Chris@16
|
20
|
Chris@16
|
21 #include <boost/version.hpp>
|
Chris@16
|
22 #include <boost/graph/graph_traits.hpp>
|
Chris@16
|
23 #include <boost/graph/graph_concepts.hpp>
|
Chris@16
|
24 #include <boost/concept/assert.hpp>
|
Chris@16
|
25
|
Chris@16
|
26 #if BOOST_VERSION >= 103500
|
Chris@16
|
27 # include <boost/concept/detail/concept_def.hpp>
|
Chris@16
|
28 #endif
|
Chris@16
|
29
|
Chris@16
|
30 namespace boost {
|
Chris@16
|
31
|
Chris@16
|
32 #if BOOST_VERSION >= 103500
|
Chris@16
|
33 namespace concepts {
|
Chris@16
|
34 #endif
|
Chris@16
|
35
|
Chris@16
|
36 #if BOOST_VERSION < 103500
|
Chris@16
|
37
|
Chris@16
|
38 template <class G>
|
Chris@16
|
39 struct DistributedVertexListGraphConcept
|
Chris@16
|
40 {
|
Chris@16
|
41 typedef typename graph_traits<G>::vertex_iterator vertex_iterator;
|
Chris@16
|
42 typedef typename graph_traits<G>::vertices_size_type vertices_size_type;
|
Chris@16
|
43 typedef typename graph_traits<G>::traversal_category
|
Chris@16
|
44 traversal_category;
|
Chris@16
|
45 void constraints() {
|
Chris@16
|
46 BOOST_CONCEPT_ASSERT(( GraphConcept<G> ));
|
Chris@16
|
47 BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept<vertex_iterator> ));
|
Chris@16
|
48 BOOST_CONCEPT_ASSERT(( ConvertibleConcept<traversal_category,
|
Chris@16
|
49 distributed_vertex_list_graph_tag> ));
|
Chris@16
|
50
|
Chris@16
|
51 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
Chris@16
|
52 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
Chris@16
|
53 // you want to use vector_as_graph, it is! I'm sure the graph
|
Chris@16
|
54 // library leaves these out all over the place. Probably a
|
Chris@16
|
55 // redesign involving specializing a template with a static
|
Chris@16
|
56 // member function is in order :(
|
Chris@16
|
57 using boost::vertices;
|
Chris@16
|
58 #endif
|
Chris@16
|
59 p = vertices(g);
|
Chris@16
|
60 v = *p.first;
|
Chris@16
|
61 const_constraints(g);
|
Chris@16
|
62 }
|
Chris@16
|
63 void const_constraints(const G& cg) {
|
Chris@16
|
64 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
Chris@16
|
65 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
Chris@16
|
66 // you want to use vector_as_graph, it is! I'm sure the graph
|
Chris@16
|
67 // library leaves these out all over the place. Probably a
|
Chris@16
|
68 // redesign involving specializing a template with a static
|
Chris@16
|
69 // member function is in order :(
|
Chris@16
|
70 using boost::vertices;
|
Chris@16
|
71 #endif
|
Chris@16
|
72
|
Chris@16
|
73 p = vertices(cg);
|
Chris@16
|
74 v = *p.first;
|
Chris@16
|
75 V = num_vertices(cg);
|
Chris@16
|
76 }
|
Chris@16
|
77 std::pair<vertex_iterator,vertex_iterator> p;
|
Chris@16
|
78 typename graph_traits<G>::vertex_descriptor v;
|
Chris@16
|
79 G g;
|
Chris@16
|
80 vertices_size_type V;
|
Chris@16
|
81 };
|
Chris@16
|
82
|
Chris@16
|
83 template <class G>
|
Chris@16
|
84 struct DistributedEdgeListGraphConcept
|
Chris@16
|
85 {
|
Chris@16
|
86 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
Chris@16
|
87 typedef typename graph_traits<G>::edge_iterator edge_iterator;
|
Chris@16
|
88 typedef typename graph_traits<G>::edges_size_type edges_size_type;
|
Chris@16
|
89 typedef typename graph_traits<G>::traversal_category
|
Chris@16
|
90 traversal_category;
|
Chris@16
|
91 void constraints() {
|
Chris@16
|
92 BOOST_CONCEPT_ASSERT(( GraphConcept<G> ));
|
Chris@16
|
93 BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept<edge_iterator> ));
|
Chris@16
|
94 BOOST_CONCEPT_ASSERT(( DefaultConstructibleConcept<edge_descriptor> ));
|
Chris@16
|
95 BOOST_CONCEPT_ASSERT(( EqualityComparableConcept<edge_descriptor> ));
|
Chris@16
|
96 BOOST_CONCEPT_ASSERT(( AssignableConcept<edge_descriptor> ));
|
Chris@16
|
97 BOOST_CONCEPT_ASSERT(( ConvertibleConcept<traversal_category,
|
Chris@16
|
98 distributed_edge_list_graph_tag> ));
|
Chris@16
|
99
|
Chris@16
|
100 p = edges(g);
|
Chris@16
|
101 e = *p.first;
|
Chris@16
|
102 u = source(e, g);
|
Chris@16
|
103 v = target(e, g);
|
Chris@16
|
104 const_constraints(g);
|
Chris@16
|
105 }
|
Chris@16
|
106 void const_constraints(const G& cg) {
|
Chris@16
|
107 p = edges(cg);
|
Chris@16
|
108 E = num_edges(cg);
|
Chris@16
|
109 e = *p.first;
|
Chris@16
|
110 u = source(e, cg);
|
Chris@16
|
111 v = target(e, cg);
|
Chris@16
|
112 }
|
Chris@16
|
113 std::pair<edge_iterator,edge_iterator> p;
|
Chris@16
|
114 typename graph_traits<G>::vertex_descriptor u, v;
|
Chris@16
|
115 typename graph_traits<G>::edge_descriptor e;
|
Chris@16
|
116 edges_size_type E;
|
Chris@16
|
117 G g;
|
Chris@16
|
118 };
|
Chris@16
|
119 #else
|
Chris@16
|
120 BOOST_concept(DistributedVertexListGraph,(G))
|
Chris@16
|
121 : Graph<G>
|
Chris@16
|
122 {
|
Chris@16
|
123 typedef typename graph_traits<G>::vertex_iterator vertex_iterator;
|
Chris@16
|
124 typedef typename graph_traits<G>::vertices_size_type vertices_size_type;
|
Chris@16
|
125 typedef typename graph_traits<G>::traversal_category
|
Chris@16
|
126 traversal_category;
|
Chris@16
|
127 ~DistributedVertexListGraph() {
|
Chris@16
|
128 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<vertex_iterator>));
|
Chris@16
|
129 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
|
Chris@16
|
130 distributed_vertex_list_graph_tag>));
|
Chris@16
|
131
|
Chris@16
|
132 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
Chris@16
|
133 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
Chris@16
|
134 // you want to use vector_as_graph, it is! I'm sure the graph
|
Chris@16
|
135 // library leaves these out all over the place. Probably a
|
Chris@16
|
136 // redesign involving specializing a template with a static
|
Chris@16
|
137 // member function is in order :(
|
Chris@16
|
138 using boost::vertices;
|
Chris@16
|
139 #endif
|
Chris@16
|
140 p = vertices(g);
|
Chris@16
|
141 v = *p.first;
|
Chris@16
|
142 const_constraints(g);
|
Chris@16
|
143 }
|
Chris@16
|
144 void const_constraints(const G& cg) {
|
Chris@16
|
145 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
|
Chris@16
|
146 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
|
Chris@16
|
147 // you want to use vector_as_graph, it is! I'm sure the graph
|
Chris@16
|
148 // library leaves these out all over the place. Probably a
|
Chris@16
|
149 // redesign involving specializing a template with a static
|
Chris@16
|
150 // member function is in order :(
|
Chris@16
|
151 using boost::vertices;
|
Chris@16
|
152 #endif
|
Chris@16
|
153
|
Chris@16
|
154 p = vertices(cg);
|
Chris@16
|
155 v = *p.first;
|
Chris@16
|
156 V = num_vertices(cg);
|
Chris@16
|
157 }
|
Chris@16
|
158 std::pair<vertex_iterator,vertex_iterator> p;
|
Chris@16
|
159 typename graph_traits<G>::vertex_descriptor v;
|
Chris@16
|
160 G g;
|
Chris@16
|
161 vertices_size_type V;
|
Chris@16
|
162 };
|
Chris@16
|
163
|
Chris@16
|
164 BOOST_concept(DistributedEdgeListGraph,(G))
|
Chris@16
|
165 : Graph<G>
|
Chris@16
|
166 {
|
Chris@16
|
167 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
Chris@16
|
168 typedef typename graph_traits<G>::edge_iterator edge_iterator;
|
Chris@16
|
169 typedef typename graph_traits<G>::edges_size_type edges_size_type;
|
Chris@16
|
170 typedef typename graph_traits<G>::traversal_category
|
Chris@16
|
171 traversal_category;
|
Chris@16
|
172 ~DistributedEdgeListGraph() {
|
Chris@16
|
173 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<edge_iterator>));
|
Chris@16
|
174 BOOST_CONCEPT_ASSERT((DefaultConstructible<edge_descriptor>));
|
Chris@16
|
175 BOOST_CONCEPT_ASSERT((EqualityComparable<edge_descriptor>));
|
Chris@16
|
176 BOOST_CONCEPT_ASSERT((Assignable<edge_descriptor>));
|
Chris@16
|
177 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
|
Chris@16
|
178 distributed_edge_list_graph_tag>));
|
Chris@16
|
179
|
Chris@16
|
180 p = edges(g);
|
Chris@16
|
181 e = *p.first;
|
Chris@16
|
182 u = source(e, g);
|
Chris@16
|
183 v = target(e, g);
|
Chris@16
|
184 const_constraints(g);
|
Chris@16
|
185 }
|
Chris@16
|
186 void const_constraints(const G& cg) {
|
Chris@16
|
187 p = edges(cg);
|
Chris@16
|
188 E = num_edges(cg);
|
Chris@16
|
189 e = *p.first;
|
Chris@16
|
190 u = source(e, cg);
|
Chris@16
|
191 v = target(e, cg);
|
Chris@16
|
192 }
|
Chris@16
|
193 std::pair<edge_iterator,edge_iterator> p;
|
Chris@16
|
194 typename graph_traits<G>::vertex_descriptor u, v;
|
Chris@16
|
195 typename graph_traits<G>::edge_descriptor e;
|
Chris@16
|
196 edges_size_type E;
|
Chris@16
|
197 G g;
|
Chris@16
|
198 };
|
Chris@16
|
199 #endif
|
Chris@16
|
200
|
Chris@16
|
201 #if BOOST_VERSION >= 103500
|
Chris@16
|
202 } // end namespace concepts
|
Chris@16
|
203
|
Chris@16
|
204 using concepts::DistributedVertexListGraphConcept;
|
Chris@16
|
205 using concepts::DistributedEdgeListGraphConcept;
|
Chris@16
|
206 #endif
|
Chris@16
|
207 } // end namespace boost
|
Chris@16
|
208
|
Chris@16
|
209 #if BOOST_VERSION >= 103500
|
Chris@16
|
210 # include <boost/concept/detail/concept_undef.hpp>
|
Chris@16
|
211 #endif
|
Chris@16
|
212
|
Chris@16
|
213 #endif // BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP
|