mirror of
https://github.com/boostorg/graph.git
synced 2026-01-30 07:52:10 +00:00
some concept checking changes as per review comments
[SVN r8268]
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
#include <boost/graph/stanford_graph.hpp>
|
||||
|
||||
//
|
||||
// These concept checks verify that the GGCL classes implement the
|
||||
// These concept checks verify that the BGL classes implement the
|
||||
// complete interfaces defined in the graph concepts. The concept
|
||||
// checks are also useful for verifying whether user-defined graph
|
||||
// classes satisfy the desired graph concepts. Note that these concept
|
||||
@@ -48,14 +48,14 @@ main(int,char*[])
|
||||
> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::edge_descriptor Edge;
|
||||
REQUIRE(Graph, VertexAndEdgeListGraph);
|
||||
REQUIRE(Graph, MutableGraph);
|
||||
REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph);
|
||||
REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept);
|
||||
// the builtin id property is readable but not writable
|
||||
typedef property_map<Graph, vertex_index_t>::const_type IndexMap;
|
||||
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
REQUIRE2(IndexMap, Vertex, ReadablePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES2(IndexMap, Vertex, ReadablePropertyMapConcept);
|
||||
}
|
||||
{
|
||||
typedef adjacency_list<vecS, vecS, bidirectionalS,
|
||||
@@ -64,15 +64,15 @@ main(int,char*[])
|
||||
> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::edge_descriptor Edge;
|
||||
REQUIRE(Graph, VertexAndEdgeListGraph);
|
||||
REQUIRE(Graph, BidirectionalGraph);
|
||||
REQUIRE(Graph, MutableGraph);
|
||||
REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph);
|
||||
REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, BidirectionalGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept);
|
||||
// the builtin id property is readable but not writable
|
||||
typedef property_map<Graph, vertex_index_t>::const_type IndexMap;
|
||||
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
REQUIRE2(IndexMap, Vertex, ReadablePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES2(IndexMap, Vertex, ReadablePropertyMapConcept);
|
||||
}
|
||||
{
|
||||
typedef adjacency_list< listS, listS, directedS,
|
||||
@@ -81,10 +81,10 @@ main(int,char*[])
|
||||
> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::edge_descriptor Edge;
|
||||
REQUIRE(Graph, VertexAndEdgeListGraph);
|
||||
REQUIRE(Graph, MutableGraph);
|
||||
REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph);
|
||||
REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept);
|
||||
}
|
||||
{
|
||||
typedef adjacency_list< listS, listS, undirectedS,
|
||||
@@ -93,19 +93,19 @@ main(int,char*[])
|
||||
> Graph;
|
||||
typedef graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typedef graph_traits<Graph>::edge_descriptor Edge;
|
||||
REQUIRE(Graph, VertexAndEdgeListGraph);
|
||||
REQUIRE(Graph, MutableGraph);
|
||||
REQUIRE3(Graph, Vertex, vertex_color_t, PropertyGraph);
|
||||
REQUIRE3(Graph, Edge, edge_weight_t, PropertyGraph);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, VertexAndEdgeListGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, MutableGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Vertex, vertex_color_t, PropertyGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(Graph, Edge, edge_weight_t, PropertyGraphConcept);
|
||||
}
|
||||
{
|
||||
typedef std::pair<int,int> E;
|
||||
typedef edge_list<E*,E,ptrdiff_t> EdgeList;
|
||||
REQUIRE(EdgeList, EdgeListGraph);
|
||||
BOOST_FUNCTION_REQUIRES(EdgeList, EdgeListGraphConcept);
|
||||
}
|
||||
{ // Stanford GraphBase Graph
|
||||
typedef Graph* Graph;
|
||||
REQUIRE(Graph, VertexListGraph);
|
||||
BOOST_FUNCTION_REQUIRES(Graph, VertexListGraphConcept);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -104,12 +104,12 @@ namespace boost {
|
||||
typedef typename graph_traits<EdgeListGraph>::edge_descriptor Edge;
|
||||
typedef typename graph_traits<EdgeListGraph>::vertex_descriptor
|
||||
Vertex;
|
||||
REQUIRE2(DistanceMap, Vertex, ReadWritePropertyMap);
|
||||
REQUIRE2(WeightMap, Edge, ReadablePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES2(DistanceMap, Vertex, ReadWritePropertyMapConcept);
|
||||
BOOST_FUNCTION_REQUIRES2(WeightMap, Edge, ReadablePropertyMapConcept);
|
||||
typedef typename property_traits<DistanceMap>::value_type D_value;
|
||||
typedef typename property_traits<WeightMap>::value_type W_value;
|
||||
REQUIRE(D_value, LessThanComparable);
|
||||
REQUIRE3(D_value, D_value, W_value, _OP_PLUS);
|
||||
BOOST_FUNCTION_REQUIRES(D_value, ComparableConcept);
|
||||
BOOST_FUNCTION_REQUIRES3(D_value, D_value, W_value, PlusOpConcept);
|
||||
std::plus<D_value> combine;
|
||||
std::less<D_value> compare;
|
||||
return bellman_ford_shortest_paths(g, N, weight, distance,
|
||||
@@ -126,15 +126,16 @@ namespace boost {
|
||||
BinaryPredicate compare,
|
||||
BellmanFordVisitor v)
|
||||
{
|
||||
REQUIRE(EdgeListGraph, EdgeListGraph);
|
||||
typedef typename graph_traits<EdgeListGraph>::edge_descriptor Edge;
|
||||
typedef typename graph_traits<EdgeListGraph>::vertex_descriptor Vertex;
|
||||
REQUIRE2(DistanceMap, Vertex, ReadWritePropertyMap);
|
||||
REQUIRE2(WeightMap, Edge, ReadablePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES(EdgeListGraph, EdgeListGraphConcept);
|
||||
typedef graph_traits<EdgeListGraph> 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);
|
||||
typedef typename property_traits<DistanceMap>::value_type D_value;
|
||||
typedef typename property_traits<WeightMap>::value_type W_value;
|
||||
|
||||
typename graph_traits<EdgeListGraph>::edge_iterator i, end;
|
||||
typename GTraits::edge_iterator i, end;
|
||||
|
||||
for (Size k = 0; k < N; ++k)
|
||||
for (tie(i, end) = edges(g); i != end; ++i) {
|
||||
|
||||
@@ -91,11 +91,12 @@ namespace boost {
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
{
|
||||
REQUIRE(IncidenceGraph, IncidenceGraph);
|
||||
typedef typename graph_traits<IncidenceGraph>::vertex_descriptor Vertex;
|
||||
typedef typename graph_traits<IncidenceGraph>::edge_descriptor Edge;
|
||||
REQUIRE2(BFSVisitor, IncidenceGraph, BFSVisitor);
|
||||
REQUIRE2(ColorMap, Vertex, ReadWritePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept);
|
||||
typedef graph_traits<IncidenceGraph> 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);
|
||||
typename property_traits<ColorMap>::value_type c = get(color, s);
|
||||
|
||||
put(color, s, gray(c));
|
||||
@@ -105,7 +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::graph_traits<IncidenceGraph>::out_edge_iterator
|
||||
typename boost::GTraits::out_edge_iterator
|
||||
ei, ei_end;
|
||||
for (tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) {
|
||||
Edge e = *ei;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace boost {
|
||||
void
|
||||
depth_first_search(VertexListGraph& g, DFSVisitor vis, ColorMap color)
|
||||
{
|
||||
REQUIRE2(DFSVisitor, VertexListGraph, DFSVisitor);
|
||||
BOOST_FUNCTION_REQUIRES2(DFSVisitor, VertexListGraph, DFSVisitorConcept);
|
||||
typename property_traits<ColorMap>::value_type
|
||||
c = get(color, *vertices(g).first); // value of c not used, just type
|
||||
|
||||
@@ -91,8 +91,8 @@ namespace boost {
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor u,
|
||||
DFSVisitor& vis, ColorMap color)
|
||||
{
|
||||
REQUIRE(IncidenceGraph, IncidenceGraph);
|
||||
REQUIRE2(DFSVisitor, IncidenceGraph, DFSVisitor);
|
||||
BOOST_FUNCTION_REQUIRES(IncidenceGraph, IncidenceGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES2(DFSVisitor, IncidenceGraph, DFSVisitorConcept);
|
||||
typename property_traits<ColorMap>::value_type c = get(color, u);
|
||||
|
||||
put(color, u, gray(c));
|
||||
|
||||
@@ -38,9 +38,9 @@
|
||||
namespace boost {
|
||||
|
||||
template <class T>
|
||||
struct MultiPassInputIterator_concept {
|
||||
struct MultiPassInputIteratorConcept {
|
||||
void constraints() {
|
||||
REQUIRE(T, InputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(T, InputIteratorConcept);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace boost {
|
||||
// add directed_category in a couple places
|
||||
|
||||
template <class G>
|
||||
struct Graph_concept
|
||||
struct GraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>
|
||||
::vertex_descriptor vertex_descriptor;
|
||||
@@ -58,24 +58,24 @@ namespace boost {
|
||||
typedef typename graph_traits<G>::edge_parallel_category
|
||||
edge_parallel_category;
|
||||
void constraints() {
|
||||
REQUIRE(vertex_descriptor, DefaultConstructible);
|
||||
REQUIRE(vertex_descriptor, EqualityComparable);
|
||||
REQUIRE(vertex_descriptor, Assignable);
|
||||
REQUIRE(edge_descriptor, DefaultConstructible);
|
||||
REQUIRE(edge_descriptor, EqualityComparable);
|
||||
REQUIRE(edge_descriptor, Assignable);
|
||||
BOOST_FUNCTION_REQUIRES(vertex_descriptor, DefaultConstructibleConcept);
|
||||
BOOST_FUNCTION_REQUIRES(vertex_descriptor, EqualityComparableConcept);
|
||||
BOOST_FUNCTION_REQUIRES(vertex_descriptor, AssignableConcept);
|
||||
BOOST_FUNCTION_REQUIRES(edge_descriptor, DefaultConstructibleConcept);
|
||||
BOOST_FUNCTION_REQUIRES(edge_descriptor, EqualityComparableConcept);
|
||||
BOOST_FUNCTION_REQUIRES(edge_descriptor, AssignableConcept);
|
||||
}
|
||||
G g;
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct IncidenceGraph_concept
|
||||
struct IncidenceGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::out_edge_iterator
|
||||
out_edge_iterator;
|
||||
void constraints() {
|
||||
REQUIRE(G, Graph);
|
||||
REQUIRE(out_edge_iterator, MultiPassInputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(G, GraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(out_edge_iterator, MultiPassInputIteratorConcept);
|
||||
|
||||
p = out_edges(v, g);
|
||||
e = *p.first;
|
||||
@@ -95,13 +95,13 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct BidirectionalGraph_concept
|
||||
struct BidirectionalGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::in_edge_iterator
|
||||
in_edge_iterator;
|
||||
void constraints() {
|
||||
REQUIRE(G, IncidenceGraph);
|
||||
REQUIRE(in_edge_iterator, MultiPassInputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(G, IncidenceGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(in_edge_iterator, MultiPassInputIteratorConcept);
|
||||
|
||||
p = in_edges(v, g);
|
||||
e = *p.first;
|
||||
@@ -118,13 +118,13 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct AdjacencyGraph_concept
|
||||
struct AdjacencyGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::adjacency_iterator
|
||||
adjacency_iterator;
|
||||
void constraints() {
|
||||
REQUIRE(G, Graph);
|
||||
REQUIRE(adjacency_iterator, MultiPassInputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(G, GraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(adjacency_iterator, MultiPassInputIteratorConcept);
|
||||
|
||||
p = adjacent_vertices(v, g);
|
||||
v = *p.first;
|
||||
@@ -139,14 +139,14 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct VertexListGraph_concept
|
||||
struct VertexListGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::vertex_iterator vertex_iterator;
|
||||
typedef typename graph_traits<G>::vertices_size_type vertices_size_type;
|
||||
void constraints() {
|
||||
REQUIRE(G, AdjacencyGraph);
|
||||
REQUIRE(G, IncidenceGraph);
|
||||
REQUIRE(vertex_iterator, MultiPassInputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(G, AdjacencyGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(G, IncidenceGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(vertex_iterator, MultiPassInputIteratorConcept);
|
||||
|
||||
p = vertices(g);
|
||||
v = *p.first;
|
||||
@@ -164,13 +164,13 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct EdgeListGraph_concept
|
||||
struct EdgeListGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::edge_iterator edge_iterator;
|
||||
typedef typename graph_traits<G>::edges_size_type edges_size_type;
|
||||
void constraints() {
|
||||
REQUIRE(G, Graph);
|
||||
REQUIRE(edge_iterator, MultiPassInputIterator);
|
||||
BOOST_FUNCTION_REQUIRES(G, GraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(edge_iterator, MultiPassInputIteratorConcept);
|
||||
|
||||
p = edges(g);
|
||||
e = *p.first;
|
||||
@@ -193,16 +193,16 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct VertexAndEdgeListGraph_concept
|
||||
struct VertexAndEdgeListGraphConcept
|
||||
{
|
||||
void constraints() {
|
||||
REQUIRE(G, VertexListGraph);
|
||||
REQUIRE(G, EdgeListGraph);
|
||||
BOOST_FUNCTION_REQUIRES(G, VertexListGraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES(G, EdgeListGraphConcept);
|
||||
}
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutableGraph_concept
|
||||
struct MutableGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
@@ -222,11 +222,11 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct MutablePropertyGraph_concept
|
||||
struct MutablePropertyGraphConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
REQUIRE(G, MutableGraph);
|
||||
BOOST_FUNCTION_REQUIRES(G, MutableGraphConcept);
|
||||
v = add_vertex(vp, g);
|
||||
p = add_edge(u, v, ep, g);
|
||||
}
|
||||
@@ -238,11 +238,11 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G>
|
||||
struct AdjacencyMatrix_concept
|
||||
struct AdjacencyMatrixConcept
|
||||
{
|
||||
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
|
||||
void constraints() {
|
||||
REQUIRE(G, Graph);
|
||||
BOOST_FUNCTION_REQUIRES(G, GraphConcept);
|
||||
|
||||
p = edge(u, v, g);
|
||||
const_constraints(g);
|
||||
@@ -256,14 +256,14 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class G, class X, class Property>
|
||||
struct PropertyGraph_concept
|
||||
struct PropertyGraphConcept
|
||||
{
|
||||
typedef typename property_map<G, Property>::type Map;
|
||||
typedef typename property_map<G, Property>::const_type const_Map;
|
||||
void constraints() {
|
||||
REQUIRE(G, Graph);
|
||||
REQUIRE2(Map, X, ReadWritePropertyMap);
|
||||
REQUIRE2(const_Map, X, ReadablePropertyMap);
|
||||
BOOST_FUNCTION_REQUIRES(G, GraphConcept);
|
||||
BOOST_FUNCTION_REQUIRES2(Map, X, ReadWritePropertyMapConcept);
|
||||
BOOST_FUNCTION_REQUIRES2(const_Map, X, ReadablePropertyMapConcept);
|
||||
|
||||
Map pmap = get(Property(), g);
|
||||
pval = get(Property(), g, x);
|
||||
@@ -282,7 +282,7 @@ namespace boost {
|
||||
|
||||
// This needs to move out of the graph library
|
||||
template <class B>
|
||||
struct Buffer_concept
|
||||
struct BufferConcept
|
||||
{
|
||||
void constraints() {
|
||||
b.push(t);
|
||||
@@ -304,11 +304,11 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <class C>
|
||||
struct ColorValue_concept
|
||||
struct ColorValueConcept
|
||||
{
|
||||
void constraints() {
|
||||
REQUIRE(C, EqualityComparable);
|
||||
REQUIRE(C, DefaultConstructible);
|
||||
BOOST_FUNCTION_REQUIRES(C, EqualityComparableConcept);
|
||||
BOOST_FUNCTION_REQUIRES(C, DefaultConstructibleConcept);
|
||||
|
||||
c = white(c);
|
||||
c = gray(c);
|
||||
|
||||
@@ -62,7 +62,8 @@ namespace {
|
||||
inline bool
|
||||
isws (char c, char const * const wstr)
|
||||
{
|
||||
return (std::strchr(wstr,c) != NULL);
|
||||
using namespace std;
|
||||
return (strchr(wstr,c) != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user