annotate DEPENDENCIES/generic/include/boost/graph/graph_concepts.hpp @ 71:37586661a088

Start sketching summarise script
author Chris Cannam
date Wed, 29 Oct 2014 17:38:24 +0000
parents 2665513ce2d3
children c530137014c0
rev   line source
Chris@16 1 //
Chris@16 2 //=======================================================================
Chris@16 3 // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
Chris@16 4 // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
Chris@16 5 //
Chris@16 6 // Copyright 2009, Andrew Sutton
Chris@16 7 //
Chris@16 8 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 9 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 10 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 11 //=======================================================================
Chris@16 12 //
Chris@16 13 #ifndef BOOST_GRAPH_CONCEPTS_HPP
Chris@16 14 #define BOOST_GRAPH_CONCEPTS_HPP
Chris@16 15
Chris@16 16 #include <boost/config.hpp>
Chris@16 17 #include <boost/property_map/property_map.hpp>
Chris@16 18 #include <boost/graph/graph_traits.hpp>
Chris@16 19 #include <boost/graph/properties.hpp>
Chris@16 20 #include <boost/graph/numeric_values.hpp>
Chris@16 21 #include <boost/graph/buffer_concepts.hpp>
Chris@16 22 #include <boost/concept_check.hpp>
Chris@16 23 #include <boost/type_traits/is_same.hpp>
Chris@16 24 #include <boost/mpl/not.hpp>
Chris@16 25 #include <boost/static_assert.hpp>
Chris@16 26 #include <boost/detail/workaround.hpp>
Chris@16 27 #include <boost/concept/assert.hpp>
Chris@16 28
Chris@16 29 #include <boost/concept/detail/concept_def.hpp>
Chris@16 30 namespace boost
Chris@16 31 {
Chris@16 32 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
Chris@16 33 // you want to use vector_as_graph, it is! I'm sure the graph
Chris@16 34 // library leaves these out all over the place. Probably a
Chris@16 35 // redesign involving specializing a template with a static
Chris@16 36 // member function is in order :(
Chris@16 37 //
Chris@16 38 // It is needed in order to allow us to write using boost::vertices as
Chris@16 39 // needed for ADL when using vector_as_graph below.
Chris@16 40 #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) \
Chris@16 41 && !BOOST_WORKAROUND(__GNUC__, <= 2) \
Chris@16 42 && !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
Chris@16 43 # define BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
Chris@16 44 #endif
Chris@16 45
Chris@16 46 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
Chris@16 47 template <class T>
Chris@16 48 typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
Chris@16 49 #endif
Chris@16 50
Chris@16 51 namespace concepts {
Chris@16 52 BOOST_concept(MultiPassInputIterator,(T)) {
Chris@16 53 BOOST_CONCEPT_USAGE(MultiPassInputIterator) {
Chris@16 54 BOOST_CONCEPT_ASSERT((InputIterator<T>));
Chris@16 55 }
Chris@16 56 };
Chris@16 57
Chris@16 58 BOOST_concept(Graph,(G))
Chris@16 59 {
Chris@16 60 typedef typename graph_traits<G>::vertex_descriptor vertex_descriptor;
Chris@16 61 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 62 typedef typename graph_traits<G>::directed_category directed_category;
Chris@16 63 typedef typename graph_traits<G>::edge_parallel_category edge_parallel_category;
Chris@16 64 typedef typename graph_traits<G>::traversal_category traversal_category;
Chris@16 65
Chris@16 66 BOOST_CONCEPT_USAGE(Graph)
Chris@16 67 {
Chris@16 68 BOOST_CONCEPT_ASSERT((DefaultConstructible<vertex_descriptor>));
Chris@16 69 BOOST_CONCEPT_ASSERT((EqualityComparable<vertex_descriptor>));
Chris@16 70 BOOST_CONCEPT_ASSERT((Assignable<vertex_descriptor>));
Chris@16 71 }
Chris@16 72 G g;
Chris@16 73 };
Chris@16 74
Chris@16 75 BOOST_concept(IncidenceGraph,(G))
Chris@16 76 : Graph<G>
Chris@16 77 {
Chris@16 78 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 79 typedef typename graph_traits<G>::out_edge_iterator out_edge_iterator;
Chris@16 80 typedef typename graph_traits<G>::degree_size_type degree_size_type;
Chris@16 81 typedef typename graph_traits<G>::traversal_category traversal_category;
Chris@16 82
Chris@16 83 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<out_edge_iterator, void> >::value));
Chris@16 84 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<degree_size_type, void> >::value));
Chris@16 85
Chris@16 86 BOOST_CONCEPT_USAGE(IncidenceGraph) {
Chris@16 87 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<out_edge_iterator>));
Chris@16 88 BOOST_CONCEPT_ASSERT((DefaultConstructible<edge_descriptor>));
Chris@16 89 BOOST_CONCEPT_ASSERT((EqualityComparable<edge_descriptor>));
Chris@16 90 BOOST_CONCEPT_ASSERT((Assignable<edge_descriptor>));
Chris@16 91 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
Chris@16 92 incidence_graph_tag>));
Chris@16 93
Chris@16 94 p = out_edges(u, g);
Chris@16 95 n = out_degree(u, g);
Chris@16 96 e = *p.first;
Chris@16 97 u = source(e, g);
Chris@16 98 v = target(e, g);
Chris@16 99 const_constraints(g);
Chris@16 100 }
Chris@16 101 void const_constraints(const G& cg) {
Chris@16 102 p = out_edges(u, cg);
Chris@16 103 n = out_degree(u, cg);
Chris@16 104 e = *p.first;
Chris@16 105 u = source(e, cg);
Chris@16 106 v = target(e, cg);
Chris@16 107 }
Chris@16 108 std::pair<out_edge_iterator, out_edge_iterator> p;
Chris@16 109 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 110 typename graph_traits<G>::edge_descriptor e;
Chris@16 111 typename graph_traits<G>::degree_size_type n;
Chris@16 112 G g;
Chris@16 113 };
Chris@16 114
Chris@16 115 BOOST_concept(BidirectionalGraph,(G))
Chris@16 116 : IncidenceGraph<G>
Chris@16 117 {
Chris@16 118 typedef typename graph_traits<G>::in_edge_iterator
Chris@16 119 in_edge_iterator;
Chris@16 120 typedef typename graph_traits<G>::traversal_category
Chris@16 121 traversal_category;
Chris@16 122
Chris@16 123 BOOST_CONCEPT_USAGE(BidirectionalGraph) {
Chris@16 124 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<in_edge_iterator>));
Chris@16 125 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
Chris@16 126 bidirectional_graph_tag>));
Chris@16 127
Chris@16 128 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<in_edge_iterator, void> >::value));
Chris@16 129
Chris@16 130 p = in_edges(v, g);
Chris@16 131 n = in_degree(v, g);
Chris@16 132 e = *p.first;
Chris@16 133 const_constraints(g);
Chris@16 134 }
Chris@16 135 void const_constraints(const G& cg) {
Chris@16 136 p = in_edges(v, cg);
Chris@16 137 n = in_degree(v, cg);
Chris@16 138 e = *p.first;
Chris@16 139 }
Chris@16 140 std::pair<in_edge_iterator, in_edge_iterator> p;
Chris@16 141 typename graph_traits<G>::vertex_descriptor v;
Chris@16 142 typename graph_traits<G>::edge_descriptor e;
Chris@16 143 typename graph_traits<G>::degree_size_type n;
Chris@16 144 G g;
Chris@16 145 };
Chris@16 146
Chris@16 147 BOOST_concept(AdjacencyGraph,(G))
Chris@16 148 : Graph<G>
Chris@16 149 {
Chris@16 150 typedef typename graph_traits<G>::adjacency_iterator
Chris@16 151 adjacency_iterator;
Chris@16 152 typedef typename graph_traits<G>::traversal_category
Chris@16 153 traversal_category;
Chris@16 154
Chris@16 155 BOOST_CONCEPT_USAGE(AdjacencyGraph) {
Chris@16 156 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<adjacency_iterator>));
Chris@16 157 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
Chris@16 158 adjacency_graph_tag>));
Chris@16 159
Chris@16 160 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<adjacency_iterator, void> >::value));
Chris@16 161
Chris@16 162 p = adjacent_vertices(v, g);
Chris@16 163 v = *p.first;
Chris@16 164 const_constraints(g);
Chris@16 165 }
Chris@16 166 void const_constraints(const G& cg) {
Chris@16 167 p = adjacent_vertices(v, cg);
Chris@16 168 }
Chris@16 169 std::pair<adjacency_iterator,adjacency_iterator> p;
Chris@16 170 typename graph_traits<G>::vertex_descriptor v;
Chris@16 171 G g;
Chris@16 172 };
Chris@16 173
Chris@16 174 BOOST_concept(VertexListGraph,(G))
Chris@16 175 : Graph<G>
Chris@16 176 {
Chris@16 177 typedef typename graph_traits<G>::vertex_iterator vertex_iterator;
Chris@16 178 typedef typename graph_traits<G>::vertices_size_type vertices_size_type;
Chris@16 179 typedef typename graph_traits<G>::traversal_category
Chris@16 180 traversal_category;
Chris@16 181
Chris@16 182 BOOST_CONCEPT_USAGE(VertexListGraph) {
Chris@16 183 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<vertex_iterator>));
Chris@16 184 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
Chris@16 185 vertex_list_graph_tag>));
Chris@16 186
Chris@16 187 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<vertex_iterator, void> >::value));
Chris@16 188 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<vertices_size_type, void> >::value));
Chris@16 189
Chris@16 190 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
Chris@16 191 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
Chris@16 192 // you want to use vector_as_graph, it is! I'm sure the graph
Chris@16 193 // library leaves these out all over the place. Probably a
Chris@16 194 // redesign involving specializing a template with a static
Chris@16 195 // member function is in order :(
Chris@16 196 using boost::vertices;
Chris@16 197 #endif
Chris@16 198 p = vertices(g);
Chris@16 199 v = *p.first;
Chris@16 200 const_constraints(g);
Chris@16 201 }
Chris@16 202 void const_constraints(const G& cg) {
Chris@16 203 #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
Chris@16 204 // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
Chris@16 205 // you want to use vector_as_graph, it is! I'm sure the graph
Chris@16 206 // library leaves these out all over the place. Probably a
Chris@16 207 // redesign involving specializing a template with a static
Chris@16 208 // member function is in order :(
Chris@16 209 using boost::vertices;
Chris@16 210 #endif
Chris@16 211
Chris@16 212 p = vertices(cg);
Chris@16 213 v = *p.first;
Chris@16 214 V = num_vertices(cg);
Chris@16 215 }
Chris@16 216 std::pair<vertex_iterator,vertex_iterator> p;
Chris@16 217 typename graph_traits<G>::vertex_descriptor v;
Chris@16 218 G g;
Chris@16 219 vertices_size_type V;
Chris@16 220 };
Chris@16 221
Chris@16 222 BOOST_concept(EdgeListGraph,(G))
Chris@16 223 : Graph<G>
Chris@16 224 {
Chris@16 225 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 226 typedef typename graph_traits<G>::edge_iterator edge_iterator;
Chris@16 227 typedef typename graph_traits<G>::edges_size_type edges_size_type;
Chris@16 228 typedef typename graph_traits<G>::traversal_category
Chris@16 229 traversal_category;
Chris@16 230
Chris@16 231 BOOST_CONCEPT_USAGE(EdgeListGraph) {
Chris@16 232 BOOST_CONCEPT_ASSERT((MultiPassInputIterator<edge_iterator>));
Chris@16 233 BOOST_CONCEPT_ASSERT((DefaultConstructible<edge_descriptor>));
Chris@16 234 BOOST_CONCEPT_ASSERT((EqualityComparable<edge_descriptor>));
Chris@16 235 BOOST_CONCEPT_ASSERT((Assignable<edge_descriptor>));
Chris@16 236 BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
Chris@16 237 edge_list_graph_tag>));
Chris@16 238
Chris@16 239 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<edge_iterator, void> >::value));
Chris@16 240 BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<edges_size_type, void> >::value));
Chris@16 241
Chris@16 242 p = edges(g);
Chris@16 243 e = *p.first;
Chris@16 244 u = source(e, g);
Chris@16 245 v = target(e, g);
Chris@16 246 const_constraints(g);
Chris@16 247 }
Chris@16 248 void const_constraints(const G& cg) {
Chris@16 249 p = edges(cg);
Chris@16 250 E = num_edges(cg);
Chris@16 251 e = *p.first;
Chris@16 252 u = source(e, cg);
Chris@16 253 v = target(e, cg);
Chris@16 254 }
Chris@16 255 std::pair<edge_iterator,edge_iterator> p;
Chris@16 256 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 257 typename graph_traits<G>::edge_descriptor e;
Chris@16 258 edges_size_type E;
Chris@16 259 G g;
Chris@16 260 };
Chris@16 261
Chris@16 262 BOOST_concept(VertexAndEdgeListGraph,(G))
Chris@16 263 : VertexListGraph<G>
Chris@16 264 , EdgeListGraph<G>
Chris@16 265 {
Chris@16 266 };
Chris@16 267
Chris@16 268 // Where to put the requirement for this constructor?
Chris@16 269 // G g(n_vertices);
Chris@16 270 // Not in mutable graph, then LEDA graph's can't be models of
Chris@16 271 // MutableGraph.
Chris@16 272 BOOST_concept(EdgeMutableGraph,(G))
Chris@16 273 {
Chris@16 274 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 275
Chris@16 276 BOOST_CONCEPT_USAGE(EdgeMutableGraph) {
Chris@16 277 p = add_edge(u, v, g);
Chris@16 278 remove_edge(u, v, g);
Chris@16 279 remove_edge(e, g);
Chris@16 280 clear_vertex(v, g);
Chris@16 281 }
Chris@16 282 G g;
Chris@16 283 edge_descriptor e;
Chris@16 284 std::pair<edge_descriptor, bool> p;
Chris@16 285 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 286 };
Chris@16 287
Chris@16 288 BOOST_concept(VertexMutableGraph,(G))
Chris@16 289 {
Chris@16 290
Chris@16 291 BOOST_CONCEPT_USAGE(VertexMutableGraph) {
Chris@16 292 v = add_vertex(g);
Chris@16 293 remove_vertex(v, g);
Chris@16 294 }
Chris@16 295 G g;
Chris@16 296 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 297 };
Chris@16 298
Chris@16 299 BOOST_concept(MutableGraph,(G))
Chris@16 300 : EdgeMutableGraph<G>
Chris@16 301 , VertexMutableGraph<G>
Chris@16 302 {
Chris@16 303 };
Chris@16 304
Chris@16 305 template <class edge_descriptor>
Chris@16 306 struct dummy_edge_predicate {
Chris@16 307 bool operator()(const edge_descriptor&) const {
Chris@16 308 return false;
Chris@16 309 }
Chris@16 310 };
Chris@16 311
Chris@16 312 BOOST_concept(MutableIncidenceGraph,(G))
Chris@16 313 : MutableGraph<G>
Chris@16 314 {
Chris@16 315 BOOST_CONCEPT_USAGE(MutableIncidenceGraph) {
Chris@16 316 remove_edge(iter, g);
Chris@16 317 remove_out_edge_if(u, p, g);
Chris@16 318 }
Chris@16 319 G g;
Chris@16 320 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 321 dummy_edge_predicate<edge_descriptor> p;
Chris@16 322 typename boost::graph_traits<G>::vertex_descriptor u;
Chris@16 323 typename boost::graph_traits<G>::out_edge_iterator iter;
Chris@16 324 };
Chris@16 325
Chris@16 326 BOOST_concept(MutableBidirectionalGraph,(G))
Chris@16 327 : MutableIncidenceGraph<G>
Chris@16 328 {
Chris@16 329 BOOST_CONCEPT_USAGE(MutableBidirectionalGraph)
Chris@16 330 {
Chris@16 331 remove_in_edge_if(u, p, g);
Chris@16 332 }
Chris@16 333 G g;
Chris@16 334 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 335 dummy_edge_predicate<edge_descriptor> p;
Chris@16 336 typename boost::graph_traits<G>::vertex_descriptor u;
Chris@16 337 };
Chris@16 338
Chris@16 339 BOOST_concept(MutableEdgeListGraph,(G))
Chris@16 340 : EdgeMutableGraph<G>
Chris@16 341 {
Chris@16 342 BOOST_CONCEPT_USAGE(MutableEdgeListGraph) {
Chris@16 343 remove_edge_if(p, g);
Chris@16 344 }
Chris@16 345 G g;
Chris@16 346 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 347 dummy_edge_predicate<edge_descriptor> p;
Chris@16 348 };
Chris@16 349
Chris@16 350 BOOST_concept(VertexMutablePropertyGraph,(G))
Chris@16 351 : VertexMutableGraph<G>
Chris@16 352 {
Chris@16 353 BOOST_CONCEPT_USAGE(VertexMutablePropertyGraph) {
Chris@16 354 v = add_vertex(vp, g);
Chris@16 355 }
Chris@16 356 G g;
Chris@16 357 typename graph_traits<G>::vertex_descriptor v;
Chris@16 358 typename vertex_property_type<G>::type vp;
Chris@16 359 };
Chris@16 360
Chris@16 361 BOOST_concept(EdgeMutablePropertyGraph,(G))
Chris@16 362 : EdgeMutableGraph<G>
Chris@16 363 {
Chris@16 364 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 365
Chris@16 366 BOOST_CONCEPT_USAGE(EdgeMutablePropertyGraph) {
Chris@16 367 p = add_edge(u, v, ep, g);
Chris@16 368 }
Chris@16 369 G g;
Chris@16 370 std::pair<edge_descriptor, bool> p;
Chris@16 371 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 372 typename edge_property_type<G>::type ep;
Chris@16 373 };
Chris@16 374
Chris@16 375 BOOST_concept(AdjacencyMatrix,(G))
Chris@16 376 : Graph<G>
Chris@16 377 {
Chris@16 378 typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
Chris@16 379
Chris@16 380 BOOST_CONCEPT_USAGE(AdjacencyMatrix) {
Chris@16 381 p = edge(u, v, g);
Chris@16 382 const_constraints(g);
Chris@16 383 }
Chris@16 384 void const_constraints(const G& cg) {
Chris@16 385 p = edge(u, v, cg);
Chris@16 386 }
Chris@16 387 typename graph_traits<G>::vertex_descriptor u, v;
Chris@16 388 std::pair<edge_descriptor, bool> p;
Chris@16 389 G g;
Chris@16 390 };
Chris@16 391
Chris@16 392 BOOST_concept(ReadablePropertyGraph,(G)(X)(Property))
Chris@16 393 : Graph<G>
Chris@16 394 {
Chris@16 395 typedef typename property_map<G, Property>::const_type const_Map;
Chris@16 396
Chris@16 397 BOOST_CONCEPT_USAGE(ReadablePropertyGraph)
Chris@16 398 {
Chris@16 399 BOOST_CONCEPT_ASSERT((ReadablePropertyMapConcept<const_Map, X>));
Chris@16 400
Chris@16 401 const_constraints(g);
Chris@16 402 }
Chris@16 403 void const_constraints(const G& cg) {
Chris@16 404 const_Map pmap = get(Property(), cg);
Chris@16 405 pval = get(Property(), cg, x);
Chris@16 406 ignore_unused_variable_warning(pmap);
Chris@16 407 }
Chris@16 408 G g;
Chris@16 409 X x;
Chris@16 410 typename property_traits<const_Map>::value_type pval;
Chris@16 411 };
Chris@16 412
Chris@16 413 BOOST_concept(PropertyGraph,(G)(X)(Property))
Chris@16 414 : ReadablePropertyGraph<G, X, Property>
Chris@16 415 {
Chris@16 416 typedef typename property_map<G, Property>::type Map;
Chris@16 417 BOOST_CONCEPT_USAGE(PropertyGraph) {
Chris@16 418 BOOST_CONCEPT_ASSERT((ReadWritePropertyMapConcept<Map, X>));
Chris@16 419
Chris@16 420 Map pmap = get(Property(), g);
Chris@16 421 pval = get(Property(), g, x);
Chris@16 422 put(Property(), g, x, pval);
Chris@16 423 ignore_unused_variable_warning(pmap);
Chris@16 424 }
Chris@16 425 G g;
Chris@16 426 X x;
Chris@16 427 typename property_traits<Map>::value_type pval;
Chris@16 428 };
Chris@16 429
Chris@16 430 BOOST_concept(LvaluePropertyGraph,(G)(X)(Property))
Chris@16 431 : ReadablePropertyGraph<G, X, Property>
Chris@16 432 {
Chris@16 433 typedef typename property_map<G, Property>::type Map;
Chris@16 434 typedef typename property_map<G, Property>::const_type const_Map;
Chris@16 435
Chris@16 436 BOOST_CONCEPT_USAGE(LvaluePropertyGraph) {
Chris@16 437 BOOST_CONCEPT_ASSERT((LvaluePropertyMapConcept<const_Map, X>));
Chris@16 438
Chris@16 439 pval = get(Property(), g, x);
Chris@16 440 put(Property(), g, x, pval);
Chris@16 441 }
Chris@16 442 G g;
Chris@16 443 X x;
Chris@16 444 typename property_traits<Map>::value_type pval;
Chris@16 445 };
Chris@16 446
Chris@16 447 // The *IndexGraph concepts are "semantic" graph concpepts. These can be
Chris@16 448 // applied to describe any graph that has an index map that can be accessed
Chris@16 449 // using the get(*_index, g) method. For example, adjacency lists with
Chris@16 450 // VertexSet == vecS are implicitly models of this concept.
Chris@16 451 //
Chris@16 452 // NOTE: We could require an associated type vertex_index_type, but that
Chris@16 453 // would mean propagating that type name into graph_traits and all of the
Chris@16 454 // other graph implementations. Much easier to simply call it unsigned.
Chris@16 455
Chris@16 456 BOOST_concept(VertexIndexGraph,(Graph))
Chris@16 457 {
Chris@16 458 BOOST_CONCEPT_USAGE(VertexIndexGraph)
Chris@16 459 {
Chris@16 460 typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
Chris@16 461 typedef typename property_map<Graph, vertex_index_t>::type Map;
Chris@16 462 typedef unsigned Index; // This could be Graph::vertex_index_type
Chris@16 463 Map m = get(vertex_index, g);
Chris@16 464 Index x = get(vertex_index, g, Vertex());
Chris@16 465 ignore_unused_variable_warning(m);
Chris@16 466 ignore_unused_variable_warning(x);
Chris@16 467
Chris@16 468 // This is relaxed
Chris@16 469 renumber_vertex_indices(g);
Chris@16 470
Chris@16 471 const_constraints(g);
Chris@16 472 }
Chris@16 473 void const_constraints(const Graph& g)
Chris@16 474 {
Chris@16 475 typedef typename property_map<Graph, vertex_index_t>::const_type Map;
Chris@16 476 Map m = get(vertex_index, g);
Chris@16 477 ignore_unused_variable_warning(m);
Chris@16 478 }
Chris@16 479 private:
Chris@16 480 Graph g;
Chris@16 481 };
Chris@16 482
Chris@16 483 BOOST_concept(EdgeIndexGraph,(Graph))
Chris@16 484 {
Chris@16 485 BOOST_CONCEPT_USAGE(EdgeIndexGraph)
Chris@16 486 {
Chris@16 487 typedef typename graph_traits<Graph>::edge_descriptor Edge;
Chris@16 488 typedef typename property_map<Graph, edge_index_t>::type Map;
Chris@16 489 typedef unsigned Index; // This could be Graph::vertex_index_type
Chris@16 490 Map m = get(edge_index, g);
Chris@16 491 Index x = get(edge_index, g, Edge());
Chris@16 492 ignore_unused_variable_warning(m);
Chris@16 493 ignore_unused_variable_warning(x);
Chris@16 494
Chris@16 495 // This is relaxed
Chris@16 496 renumber_edge_indices(g);
Chris@16 497
Chris@16 498 const_constraints(g);
Chris@16 499 }
Chris@16 500 void const_constraints(const Graph& g)
Chris@16 501 {
Chris@16 502 typedef typename property_map<Graph, edge_index_t>::const_type Map;
Chris@16 503 Map m = get(edge_index, g);
Chris@16 504 ignore_unused_variable_warning(m);
Chris@16 505 }
Chris@16 506 private:
Chris@16 507 Graph g;
Chris@16 508 };
Chris@16 509
Chris@16 510 BOOST_concept(ColorValue,(C))
Chris@16 511 : EqualityComparable<C>
Chris@16 512 , DefaultConstructible<C>
Chris@16 513 {
Chris@16 514 BOOST_CONCEPT_USAGE(ColorValue) {
Chris@16 515 c = color_traits<C>::white();
Chris@16 516 c = color_traits<C>::gray();
Chris@16 517 c = color_traits<C>::black();
Chris@16 518 }
Chris@16 519 C c;
Chris@16 520 };
Chris@16 521
Chris@16 522 BOOST_concept(BasicMatrix,(M)(I)(V))
Chris@16 523 {
Chris@16 524 BOOST_CONCEPT_USAGE(BasicMatrix) {
Chris@16 525 V& elt = A[i][j];
Chris@16 526 const_constraints(A);
Chris@16 527 ignore_unused_variable_warning(elt);
Chris@16 528 }
Chris@16 529 void const_constraints(const M& cA) {
Chris@16 530 const V& elt = cA[i][j];
Chris@16 531 ignore_unused_variable_warning(elt);
Chris@16 532 }
Chris@16 533 M A;
Chris@16 534 I i, j;
Chris@16 535 };
Chris@16 536
Chris@16 537 // The following concepts describe aspects of numberic values and measure
Chris@16 538 // functions. We're extending the notion of numeric values to include
Chris@16 539 // emulation for zero and infinity.
Chris@16 540
Chris@16 541 BOOST_concept(NumericValue,(Numeric))
Chris@16 542 {
Chris@16 543 BOOST_CONCEPT_USAGE(NumericValue)
Chris@16 544 {
Chris@16 545 BOOST_CONCEPT_ASSERT(( DefaultConstructible<Numeric> ));
Chris@16 546 BOOST_CONCEPT_ASSERT(( CopyConstructible<Numeric> ));
Chris@16 547 numeric_values<Numeric>::zero();
Chris@16 548 numeric_values<Numeric>::infinity();
Chris@16 549 }
Chris@16 550 };
Chris@16 551
Chris@16 552 BOOST_concept(DegreeMeasure,(Measure)(Graph))
Chris@16 553 {
Chris@16 554 BOOST_CONCEPT_USAGE(DegreeMeasure)
Chris@16 555 {
Chris@16 556 typedef typename Measure::degree_type Degree;
Chris@16 557 typedef typename Measure::vertex_type Vertex;
Chris@16 558
Chris@16 559 Degree d = m(Vertex(), g);
Chris@16 560 ignore_unused_variable_warning(d);
Chris@16 561 }
Chris@16 562 private:
Chris@16 563 Measure m;
Chris@16 564 Graph g;
Chris@16 565 };
Chris@16 566
Chris@16 567 BOOST_concept(DistanceMeasure,(Measure)(Graph))
Chris@16 568 {
Chris@16 569 BOOST_CONCEPT_USAGE(DistanceMeasure)
Chris@16 570 {
Chris@16 571 typedef typename Measure::distance_type Distance;
Chris@16 572 typedef typename Measure::result_type Result;
Chris@16 573 Result r = m(Distance(), g);
Chris@16 574 ignore_unused_variable_warning(r);
Chris@16 575 }
Chris@16 576 private:
Chris@16 577 Measure m;
Chris@16 578 Graph g;
Chris@16 579 };
Chris@16 580
Chris@16 581 } /* namespace concepts */
Chris@16 582
Chris@16 583 using boost::concepts::MultiPassInputIteratorConcept;
Chris@16 584
Chris@16 585 // Graph concepts
Chris@16 586 using boost::concepts::GraphConcept;
Chris@16 587 using boost::concepts::IncidenceGraphConcept;
Chris@16 588 using boost::concepts::BidirectionalGraphConcept;
Chris@16 589 using boost::concepts::AdjacencyGraphConcept;
Chris@16 590 using boost::concepts::VertexListGraphConcept;
Chris@16 591 using boost::concepts::EdgeListGraphConcept;
Chris@16 592 using boost::concepts::VertexAndEdgeListGraphConcept;
Chris@16 593 using boost::concepts::EdgeMutableGraphConcept;
Chris@16 594 using boost::concepts::VertexMutableGraphConcept;
Chris@16 595 using boost::concepts::MutableGraphConcept;
Chris@16 596 using boost::concepts::MutableIncidenceGraphConcept;
Chris@16 597 using boost::concepts::MutableBidirectionalGraphConcept;
Chris@16 598 using boost::concepts::MutableEdgeListGraphConcept;
Chris@16 599 using boost::concepts::VertexMutablePropertyGraphConcept;
Chris@16 600 using boost::concepts::EdgeMutablePropertyGraphConcept;
Chris@16 601 using boost::concepts::AdjacencyMatrixConcept;
Chris@16 602 using boost::concepts::ReadablePropertyGraphConcept;
Chris@16 603 using boost::concepts::PropertyGraphConcept;
Chris@16 604 using boost::concepts::LvaluePropertyGraphConcept;
Chris@16 605 using boost::concepts::VertexIndexGraphConcept;
Chris@16 606 using boost::concepts::EdgeIndexGraphConcept;
Chris@16 607
Chris@16 608 // Utility concepts
Chris@16 609 using boost::concepts::ColorValueConcept;
Chris@16 610 using boost::concepts::BasicMatrixConcept;
Chris@16 611 using boost::concepts::NumericValueConcept;
Chris@16 612 using boost::concepts::DistanceMeasureConcept;
Chris@16 613 using boost::concepts::DegreeMeasureConcept;
Chris@16 614
Chris@16 615
Chris@16 616 } /* namespace boost */
Chris@16 617 #include <boost/concept/detail/concept_undef.hpp>
Chris@16 618
Chris@16 619 #endif /* BOOST_GRAPH_CONCEPTS_H */