diff --git a/examples/concept_checks.cpp b/examples/concept_checks.cpp index f8d0d79c..4db513bd 100644 --- a/examples/concept_checks.cpp +++ b/examples/concept_checks.cpp @@ -49,7 +49,8 @@ main(int,char*[]) typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; function_requires< VertexAndEdgeListGraphConcept >(); - function_requires< MutableGraphConcept >(); + function_requires< MutableIncidenceGraphConcept >(); + function_requires< MutableEdgeListGraphConcept >(); function_requires< PropertyGraphConcept >(); function_requires< PropertyGraphConcept >(); // the builtin id property is readable but not writable @@ -66,7 +67,8 @@ main(int,char*[]) typedef graph_traits::edge_descriptor Edge; function_requires< VertexAndEdgeListGraphConcept >(); function_requires< BidirectionalGraphConcept >(); - function_requires< MutableGraphConcept >(); + function_requires< MutableBidirectionalGraphConcept >(); + function_requires< MutableEdgeListGraphConcept >(); function_requires< PropertyGraphConcept >(); function_requires< PropertyGraphConcept >(); // the builtin id property is readable but not writable @@ -81,7 +83,8 @@ main(int,char*[]) typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; function_requires< VertexAndEdgeListGraphConcept >(); - function_requires< MutableGraphConcept >(); + function_requires< MutableIncidenceGraphConcept >(); + function_requires< MutableEdgeListGraphConcept >(); function_requires< PropertyGraphConcept >(); function_requires< PropertyGraphConcept >(); } @@ -93,7 +96,8 @@ main(int,char*[]) typedef graph_traits::vertex_descriptor Vertex; typedef graph_traits::edge_descriptor Edge; function_requires< VertexAndEdgeListGraphConcept >(); - function_requires< MutableGraphConcept >(); + function_requires< MutableBidirectionalGraphConcept >(); + function_requires< MutableEdgeListGraphConcept >(); function_requires< PropertyGraphConcept >(); function_requires< PropertyGraphConcept >(); } diff --git a/examples/connected_components.cpp b/examples/connected_components.cpp index e5d97354..d5eee457 100644 --- a/examples/connected_components.cpp +++ b/examples/connected_components.cpp @@ -73,7 +73,7 @@ int main(int , char* []) property< vertex_finish_time_t, int, property< vertex_color_t, default_color_type > > > VertexProperty; typedef adjacency_list Graph; - typedef Graph::vertex_descriptor Vertex; + typedef graph_traits::vertex_descriptor Vertex; Graph G; add_edge(0, 1, G); @@ -111,7 +111,7 @@ int main(int , char* []) add_edge(3, 0, G); add_edge(5, 2, G); - typedef Graph::vertex_descriptor Vertex; + typedef graph_traits::vertex_descriptor Vertex; std::vector c(num_vertices(G)); int num = connected_components(G, &c[0], get(vertex_color, G), diff --git a/examples/edge_iterator_constructor.cpp b/examples/edge_iterator_constructor.cpp index fbadd075..8992a446 100644 --- a/examples/edge_iterator_constructor.cpp +++ b/examples/edge_iterator_constructor.cpp @@ -110,15 +110,15 @@ main() { typedef boost::adjacency_list<> IteratorConstructibleGraph; typedef boost::graph_traits Traits; - Traits::vertices_size_type V; - Traits::edges_size_type E; + Traits::vertices_size_type size_V; + Traits::edges_size_type size_E; std::ifstream f("edge_iterator_constructor.dat"); - f >> V >> E; + f >> size_V >> size_E; edge_stream_iterator edge_iter(f), end; - IteratorConstructibleGraph G(V, edge_iter, end); + IteratorConstructibleGraph G(size_V, edge_iter, end); boost::print_graph(G); return 0; diff --git a/examples/file_dependencies.cpp b/examples/file_dependencies.cpp index 0ed18548..cdf34265 100644 --- a/examples/file_dependencies.cpp +++ b/examples/file_dependencies.cpp @@ -75,21 +75,15 @@ struct print_visitor : public bfs_visitor<> { }; -template struct cycle_detector : public dfs_visitor<> { - typedef typename boost::property_traits::value_type C; - - cycle_detector(Color c, bool& has_cycle) - : _has_cycle(has_cycle), color(c) { } + cycle_detector(bool& has_cycle) + : m_has_cycle(has_cycle) { } template - void back_edge(Edge e, Graph& g) { - _has_cycle = true; - } + void back_edge(Edge e, Graph& g) { m_has_cycle = true; } protected: - bool& _has_cycle; - Color color; + bool& m_has_cycle; }; int main(int,char*[]) @@ -124,7 +118,6 @@ int main(int,char*[]) typedef graph_traits::vertex_descriptor Vertex; typedef property_map::type Color; - Color color = get(vertex_color, g); // Determine ordering for a full recompilation { @@ -185,7 +178,7 @@ int main(int,char*[]) // are there any cycles in the graph? { bool has_cycle = false; - cycle_detector vis(color, has_cycle); + cycle_detector vis(has_cycle); depth_first_search(g, vis); cout << "The graph has a cycle? " << has_cycle << endl; } @@ -201,9 +194,8 @@ int main(int,char*[]) // are there any cycles in the graph? { typedef property_map::type Color; - Color color = get(vertex_color, g); bool has_cycle = false; - cycle_detector vis(color, has_cycle); + cycle_detector vis(has_cycle); depth_first_search(g, vis); cout << "The graph has a cycle now? " << has_cycle << endl; } diff --git a/examples/johnson.cpp b/examples/johnson.cpp index d1cb9bdc..d53e1c80 100644 --- a/examples/johnson.cpp +++ b/examples/johnson.cpp @@ -73,7 +73,7 @@ main() 6 }; int* wp = weights; - Graph::edge_iterator e,e_end; + graph_traits::edge_iterator e,e_end; for (boost::tie(e,e_end) = edges(g); e != e_end; ++e) w[*e] = *wp++; diff --git a/include/boost/graph/bellman_ford_shortest_paths.hpp b/include/boost/graph/bellman_ford_shortest_paths.hpp index 15516708..5289c17d 100644 --- a/include/boost/graph/bellman_ford_shortest_paths.hpp +++ b/include/boost/graph/bellman_ford_shortest_paths.hpp @@ -38,7 +38,7 @@ namespace boost { template - struct BellmanFordVisitor_concept { + struct BellmanFordVisitorConcept { void constraints() { vis.examine_edge(e, g); vis.edge_relaxed(e, g); @@ -104,12 +104,12 @@ namespace boost { typedef typename graph_traits::edge_descriptor Edge; typedef typename graph_traits::vertex_descriptor Vertex; - BOOST_FUNCTION_REQUIRES2(DistanceMap, Vertex, ReadWritePropertyMapConcept); - BOOST_FUNCTION_REQUIRES2(WeightMap, Edge, ReadablePropertyMapConcept); + function_requires >(); + function_requires >(); typedef typename property_traits::value_type D_value; typedef typename property_traits::value_type W_value; - BOOST_FUNCTION_REQUIRES(D_value, ComparableConcept); - BOOST_FUNCTION_REQUIRES3(D_value, D_value, W_value, PlusOpConcept); + function_requires >(); + function_requires >(); std::plus combine; std::less compare; return bellman_ford_shortest_paths(g, N, weight, distance, @@ -126,12 +126,12 @@ namespace boost { BinaryPredicate compare, BellmanFordVisitor v) { - BOOST_FUNCTION_REQUIRES(EdgeListGraph, EdgeListGraphConcept); + function_requires >(); typedef graph_traits GTraits; typedef typename GTraits::edge_descriptor Edge; typedef typename GTraits::vertex_descriptor Vertex; - BOOST_FUNCTION_REQUIRES2(DistanceMap, Vertex, ReadWritePropertyMapConcept); - BOOST_FUNCTION_REQUIRES2(WeightMap, Edge, ReadablePropertyMapConcept); + function_requires >(); + function_requires >(); typedef typename property_traits::value_type D_value; typedef typename property_traits::value_type W_value; diff --git a/include/boost/graph/breadth_first_search.hpp b/include/boost/graph/breadth_first_search.hpp index 4e4d4ada..c83658e1 100644 --- a/include/boost/graph/breadth_first_search.hpp +++ b/include/boost/graph/breadth_first_search.hpp @@ -39,7 +39,7 @@ namespace boost { template - struct BFSVisitor_concept { + struct BFSVisitorConcept { void constraints() { vis.initialize_vertex(u, g); vis.start_vertex(u, g); @@ -91,12 +91,12 @@ namespace boost { typename graph_traits::vertex_descriptor s, Buffer& Q, BFSVisitor vis, ColorMap color) { - BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept); + function_requires< IncidenceGraphConcept >(); typedef graph_traits GTraits; typedef typename GTraits::vertex_descriptor Vertex; typedef typename GTraits::edge_descriptor Edge; - BOOST_FUNCTION_REQUIRES2(BFSVisitor, IncidenceGraph, BFSVisitorConcept); - BOOST_FUNCTION_REQUIRES2(ColorMap, Vertex, ReadWritePropertyMapConcept); + function_requires< BFSVisitorConcept >(); + function_requires< ReadWritePropertyMapConcept >(); typename property_traits::value_type c = get(color, s); put(color, s, gray(c)); @@ -106,8 +106,7 @@ namespace boost { Vertex u = Q.top(); Q.pop(); // pop before push to avoid problem if Q is priority_queue. vis.discover_vertex(u, g); - typename boost::GTraits::out_edge_iterator - ei, ei_end; + typename GTraits::out_edge_iterator ei, ei_end; for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) { Edge e = *ei; vis.examine_edge(e, g); diff --git a/include/boost/graph/depth_first_search.hpp b/include/boost/graph/depth_first_search.hpp index 56917308..17ac194e 100644 --- a/include/boost/graph/depth_first_search.hpp +++ b/include/boost/graph/depth_first_search.hpp @@ -37,7 +37,7 @@ namespace boost { template - class DFSVisitor_concept { + class DFSVisitorConcept { public: void constraints() { vis.initialize_vertex(u, g); @@ -70,7 +70,7 @@ namespace boost { void depth_first_search(VertexListGraph& g, DFSVisitor vis, ColorMap color) { - BOOST_FUNCTION_REQUIRES2(DFSVisitor, VertexListGraph, DFSVisitorConcept); + function_requires >(); typename property_traits::value_type c = get(color, *vertices(g).first); // value of c not used, just type @@ -91,8 +91,8 @@ namespace boost { typename graph_traits::vertex_descriptor u, DFSVisitor& vis, ColorMap color) { - BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept); - BOOST_FUNCTION_REQUIRES2(DFSVisitor, IncidenceGraph, DFSVisitorConcept); + function_requires >(); + function_requires >(); typename property_traits::value_type c = get(color, u); put(color, u, gray(c)); diff --git a/include/boost/graph/graph_concepts.hpp b/include/boost/graph/graph_concepts.hpp index de57c596..a4799e94 100644 --- a/include/boost/graph/graph_concepts.hpp +++ b/include/boost/graph/graph_concepts.hpp @@ -210,9 +210,8 @@ namespace boost { clear_vertex(v, g); remove_vertex(v, g); p = add_edge(u, v, g); - remove_edge(u, v, g); + remove_edge(u, v, g); // Hmm, maybe this shouldn't be here... remove_edge(e, g); - remove_edge(iter, g); } G g; edge_descriptor e; @@ -221,6 +220,53 @@ namespace boost { typename graph_traits::out_edge_iterator iter; }; + template + struct dummy_edge_predicate { + bool operator()(const edge_descriptor& e) const { + return false; + } + }; + + template + struct MutableIncidenceGraphConcept + { + void constraints() { + function_requires< MutableGraphConcept >(); + remove_edge(iter, g); + remove_out_edge_if(u, p, g); + } + G g; + typedef typename graph_traits::edge_descriptor edge_descriptor; + dummy_edge_predicate p; + typename boost::graph_traits::vertex_descriptor u; + typename boost::graph_traits::out_edge_iterator iter; + }; + + template + struct MutableBidirectionalGraphConcept + { + void constraints() { + function_requires< MutableIncidenceGraphConcept >(); + remove_in_edge_if(u, p, g); + } + G g; + typedef typename graph_traits::edge_descriptor edge_descriptor; + dummy_edge_predicate p; + typename boost::graph_traits::vertex_descriptor u; + }; + + template + struct MutableEdgeListGraphConcept + { + void constraints() { + function_requires< MutableGraphConcept >(); + remove_edge_if(p, g); + } + G g; + typedef typename graph_traits::edge_descriptor edge_descriptor; + dummy_edge_predicate p; + }; + template struct MutablePropertyGraphConcept { diff --git a/include/boost/graph/kruskal_min_spanning_tree.hpp b/include/boost/graph/kruskal_min_spanning_tree.hpp index 61a28147..6aab9c27 100644 --- a/include/boost/graph/kruskal_min_spanning_tree.hpp +++ b/include/boost/graph/kruskal_min_spanning_tree.hpp @@ -76,17 +76,17 @@ namespace boost { { typedef typename graph_traits::vertex_descriptor Vertex; typedef typename graph_traits::edge_descriptor Edge; - REQUIRE(Graph, VertexAndEdgeListGraph); - REQUIRE2(OutputIterator, Edge, OutputIterator); - REQUIRE2(Rank, Vertex, ReadWritePropertyMap); - REQUIRE2(Parent, Vertex, ReadWritePropertyMap); - REQUIRE2(Weight, Edge, ReadablePropertyMap); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); typedef typename property_traits::value_type W_value; typedef typename property_traits::value_type R_value; typedef typename property_traits::value_type P_value; - REQUIRE(W_value, LessThanComparable); - REQUIRE2(P_value, Vertex, Convertible); - REQUIRE(R_value, Integer); + function_requires >(); + function_requires >(); + function_requires >(); disjoint_sets dset(rank, parent); diff --git a/include/boost/graph/uniform_cost_search.hpp b/include/boost/graph/uniform_cost_search.hpp index 51e2f63a..7e884a6e 100644 --- a/include/boost/graph/uniform_cost_search.hpp +++ b/include/boost/graph/uniform_cost_search.hpp @@ -41,7 +41,7 @@ namespace boost { template - struct UniformCostVisitor_concept { + struct UniformCostVisitorConcept { void constraints() { vis.start_vertex(u, g); vis.initialize_vertex(u, g); @@ -125,7 +125,7 @@ namespace boost { m_vis.initialize_vertex(u, g); } template - void start_vertex(Vertex v, Graph& g) { + void start_vertex(Vertex u, Graph& g) { m_vis.start_vertex(u, g); } template @@ -187,22 +187,25 @@ namespace boost { BinaryPredicate compare, BinaryFunction combine, UniformCostVisitor vis) { - REQUIRE(VertexListGraph, VertexListGraph); + function_requires >(); typedef typename graph_traits::vertex_descriptor Vertex; typedef typename graph_traits::edge_descriptor Edge; - REQUIRE2(ColorMap, Vertex, ReadWritePropertyMap); - REQUIRE2(DistanceMap, Vertex, ReadWritePropertyMap); - REQUIRE2(WeightMap, Edge, ReadablePropertyMap); - REQUIRE2(IndexMap, Vertex, ReadablePropertyMap); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); typedef typename property_traits::value_type D_value; typedef typename property_traits::value_type W_value; typedef typename property_traits::value_type ID_value; typedef typename property_traits::value_type Color_value; - REQUIRE(Color_value, ColorValue); - REQUIRE3(BinaryPredicate, D_value, D_value, BinaryPredicate); - REQUIRE4(BinaryFunction, D_value, D_value, W_value, BinaryFunction); - REQUIRE(ID_value, Integer); - REQUIRE2(UniformCostVisitor, VertexListGraph, UniformCostVisitor); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); + function_requires >(); typedef indirect_cmp IndirectCmp; IndirectCmp icmp(d, compare);