Chris@16: // Copyright (C) 2004-2006 The Trustees of Indiana University. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Authors: Douglas Gregor Chris@16: // Andrew Lumsdaine Chris@16: Chris@16: // Chris@16: // Distributed graph concepts and helpers Chris@16: // Chris@16: Chris@16: #ifndef BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP Chris@16: #define BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP Chris@16: Chris@16: #ifndef BOOST_GRAPH_USE_MPI Chris@16: #error "Parallel BGL files should not be included unless has been included" Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: #if BOOST_VERSION >= 103500 Chris@16: # include Chris@16: #endif Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: #if BOOST_VERSION >= 103500 Chris@16: namespace concepts { Chris@16: #endif Chris@16: Chris@16: #if BOOST_VERSION < 103500 Chris@16: Chris@16: template Chris@16: struct DistributedVertexListGraphConcept Chris@16: { Chris@16: typedef typename graph_traits::vertex_iterator vertex_iterator; Chris@16: typedef typename graph_traits::vertices_size_type vertices_size_type; Chris@16: typedef typename graph_traits::traversal_category Chris@16: traversal_category; Chris@16: void constraints() { Chris@16: BOOST_CONCEPT_ASSERT(( GraphConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( ConvertibleConcept )); Chris@16: Chris@16: #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK Chris@16: // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if Chris@16: // you want to use vector_as_graph, it is! I'm sure the graph Chris@16: // library leaves these out all over the place. Probably a Chris@16: // redesign involving specializing a template with a static Chris@16: // member function is in order :( Chris@16: using boost::vertices; Chris@16: #endif Chris@16: p = vertices(g); Chris@16: v = *p.first; Chris@16: const_constraints(g); Chris@16: } Chris@16: void const_constraints(const G& cg) { Chris@16: #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK Chris@16: // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if Chris@16: // you want to use vector_as_graph, it is! I'm sure the graph Chris@16: // library leaves these out all over the place. Probably a Chris@16: // redesign involving specializing a template with a static Chris@16: // member function is in order :( Chris@16: using boost::vertices; Chris@16: #endif Chris@16: Chris@16: p = vertices(cg); Chris@16: v = *p.first; Chris@16: V = num_vertices(cg); Chris@16: } Chris@16: std::pair p; Chris@16: typename graph_traits::vertex_descriptor v; Chris@16: G g; Chris@16: vertices_size_type V; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct DistributedEdgeListGraphConcept Chris@16: { Chris@16: typedef typename graph_traits::edge_descriptor edge_descriptor; Chris@16: typedef typename graph_traits::edge_iterator edge_iterator; Chris@16: typedef typename graph_traits::edges_size_type edges_size_type; Chris@16: typedef typename graph_traits::traversal_category Chris@16: traversal_category; Chris@16: void constraints() { Chris@16: BOOST_CONCEPT_ASSERT(( GraphConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( MultiPassInputIteratorConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( DefaultConstructibleConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( EqualityComparableConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( AssignableConcept )); Chris@16: BOOST_CONCEPT_ASSERT(( ConvertibleConcept )); Chris@16: Chris@16: p = edges(g); Chris@16: e = *p.first; Chris@16: u = source(e, g); Chris@16: v = target(e, g); Chris@16: const_constraints(g); Chris@16: } Chris@16: void const_constraints(const G& cg) { Chris@16: p = edges(cg); Chris@16: E = num_edges(cg); Chris@16: e = *p.first; Chris@16: u = source(e, cg); Chris@16: v = target(e, cg); Chris@16: } Chris@16: std::pair p; Chris@16: typename graph_traits::vertex_descriptor u, v; Chris@16: typename graph_traits::edge_descriptor e; Chris@16: edges_size_type E; Chris@16: G g; Chris@16: }; Chris@16: #else Chris@16: BOOST_concept(DistributedVertexListGraph,(G)) Chris@16: : Graph Chris@16: { Chris@16: typedef typename graph_traits::vertex_iterator vertex_iterator; Chris@16: typedef typename graph_traits::vertices_size_type vertices_size_type; Chris@16: typedef typename graph_traits::traversal_category Chris@16: traversal_category; Chris@16: ~DistributedVertexListGraph() { Chris@16: BOOST_CONCEPT_ASSERT((MultiPassInputIterator)); Chris@16: BOOST_CONCEPT_ASSERT((Convertible)); Chris@16: Chris@16: #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK Chris@16: // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if Chris@16: // you want to use vector_as_graph, it is! I'm sure the graph Chris@16: // library leaves these out all over the place. Probably a Chris@16: // redesign involving specializing a template with a static Chris@16: // member function is in order :( Chris@16: using boost::vertices; Chris@16: #endif Chris@16: p = vertices(g); Chris@16: v = *p.first; Chris@16: const_constraints(g); Chris@16: } Chris@16: void const_constraints(const G& cg) { Chris@16: #ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK Chris@16: // dwa 2003/7/11 -- This clearly shouldn't be necessary, but if Chris@16: // you want to use vector_as_graph, it is! I'm sure the graph Chris@16: // library leaves these out all over the place. Probably a Chris@16: // redesign involving specializing a template with a static Chris@16: // member function is in order :( Chris@16: using boost::vertices; Chris@16: #endif Chris@16: Chris@16: p = vertices(cg); Chris@16: v = *p.first; Chris@16: V = num_vertices(cg); Chris@16: } Chris@16: std::pair p; Chris@16: typename graph_traits::vertex_descriptor v; Chris@16: G g; Chris@16: vertices_size_type V; Chris@16: }; Chris@16: Chris@16: BOOST_concept(DistributedEdgeListGraph,(G)) Chris@16: : Graph Chris@16: { Chris@16: typedef typename graph_traits::edge_descriptor edge_descriptor; Chris@16: typedef typename graph_traits::edge_iterator edge_iterator; Chris@16: typedef typename graph_traits::edges_size_type edges_size_type; Chris@16: typedef typename graph_traits::traversal_category Chris@16: traversal_category; Chris@16: ~DistributedEdgeListGraph() { Chris@16: BOOST_CONCEPT_ASSERT((MultiPassInputIterator)); Chris@16: BOOST_CONCEPT_ASSERT((DefaultConstructible)); Chris@16: BOOST_CONCEPT_ASSERT((EqualityComparable)); Chris@16: BOOST_CONCEPT_ASSERT((Assignable)); Chris@16: BOOST_CONCEPT_ASSERT((Convertible)); Chris@16: Chris@16: p = edges(g); Chris@16: e = *p.first; Chris@16: u = source(e, g); Chris@16: v = target(e, g); Chris@16: const_constraints(g); Chris@16: } Chris@16: void const_constraints(const G& cg) { Chris@16: p = edges(cg); Chris@16: E = num_edges(cg); Chris@16: e = *p.first; Chris@16: u = source(e, cg); Chris@16: v = target(e, cg); Chris@16: } Chris@16: std::pair p; Chris@16: typename graph_traits::vertex_descriptor u, v; Chris@16: typename graph_traits::edge_descriptor e; Chris@16: edges_size_type E; Chris@16: G g; Chris@16: }; Chris@16: #endif Chris@16: Chris@16: #if BOOST_VERSION >= 103500 Chris@16: } // end namespace concepts Chris@16: Chris@16: using concepts::DistributedVertexListGraphConcept; Chris@16: using concepts::DistributedEdgeListGraphConcept; Chris@16: #endif Chris@16: } // end namespace boost Chris@16: Chris@16: #if BOOST_VERSION >= 103500 Chris@16: # include Chris@16: #endif Chris@16: Chris@16: #endif // BOOST_GRAPH_DISTRIBUTED_CONCEPTS_HPP