Boost logo

Boost-Commit :

From: asutton_at_[hidden]
Date: 2007-08-14 08:16:16


Author: asutton
Date: 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
New Revision: 38651
URL: http://svn.boost.org/trac/boost/changeset/38651

Log:
Added concept check for mean geodesic
Added new concept checks for measure-based calls to closeness
Added new archetypes for distance measure, degree measure

Added:
   sandbox/SOC/2007/graphs/libs/graph/test/concept/mean_geodesic_check.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2007/graphs/libs/graph/test/concept/Jamfile.v2 | 1
   sandbox/SOC/2007/graphs/libs/graph/test/concept/archetypes.hpp | 93 +++++----------------------------------
   sandbox/SOC/2007/graphs/libs/graph/test/concept/closeness_centrality_check.cpp | 3 +
   sandbox/SOC/2007/graphs/libs/graph/test/concept/degree_centrality_check.cpp | 2
   4 files changed, 19 insertions(+), 80 deletions(-)

Modified: sandbox/SOC/2007/graphs/libs/graph/test/concept/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/graphs/libs/graph/test/concept/Jamfile.v2 (original)
+++ sandbox/SOC/2007/graphs/libs/graph/test/concept/Jamfile.v2 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
@@ -10,4 +10,5 @@
 test-suite graph_test :
     [ compile degree_centrality_check.cpp ]
     [ compile closeness_centrality_check.cpp ]
+ [ compile mean_geodesic_check.cpp ]
     ;
\ No newline at end of file

Modified: sandbox/SOC/2007/graphs/libs/graph/test/concept/archetypes.hpp
==============================================================================
--- sandbox/SOC/2007/graphs/libs/graph/test/concept/archetypes.hpp (original)
+++ sandbox/SOC/2007/graphs/libs/graph/test/concept/archetypes.hpp 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
@@ -26,90 +26,23 @@
         descriptor_archetype(detail::dummy_constructor) { }
     };
 
- // Apparently, the Boost.Graph library doesn't have a bidirectional
- // archetype - kind of a strange oversight. This is actually derived
- // from incidence graph archetype in order have access to its
- // archetypical functions and members
- template <typename Vertex,
- typename Directed,
- typename Parallel,
- typename Base = detail::null_graph_archetype >
- struct bidirectional_graph_archetype : public Base
+ template <typename Graph>
+ struct degree_measure_archetype
     {
- struct traversal_category
- : public bidirectional_graph_tag
- , public Base::traversal_category
- { };
-
- typedef descriptor_archetype vertex_descriptor;
- typedef descriptor_archetype edge_descriptor;
-
- typedef unsigned int degree_size_type;
- typedef unsigned int vertices_size_type;
- typedef unsigned int edges_size_type;
-
- typedef input_iterator_archetype<edge_descriptor> out_edge_iterator;
- typedef input_iterator_archetype<edge_descriptor> in_edge_iterator;
-
- typedef Directed directed_category;
- typedef Parallel edge_parallel_category;
-
- typedef void adjacency_iterator;
- typedef void vertex_iterator;
- typedef void edge_iterator;
+ typedef typename graph_traits<Graph>::degree_size_type degree_type;
+ typedef typename graph_traits<Graph>::vertex_descriptor vertex_type;
+ degree_type operator ()(vertex_type, const Graph&)
+ { return degree_type(); }
     };
 
- /*
- template <typename V, typename D, typename P, typename B>
- typename bidirectional_graph_archetype<V,D,P,B>::vertex_descriptor
- source(typename bidirectional_graph_archetype<V,D,P,B>::edge_descriptor,
- const bidirectional_graph_archetype<V,D,P,B>&)
- {
- return V(static_object<detail::dummy_constructor>::get());
- }
-
- template <typename V, typename D, typename P, typename B>
- typename bidirectional_graph_archetype<V,D,P,B>::vertex_descriptor
- target(typename bidirectional_graph_archetype<V,D,P,B>::edge_descriptor,
- const bidirectional_graph_archetype<V,D,P,B>&)
+ template <typename Graph, typename Distance, typename Result>
+ struct distance_measure_archetype
     {
- return V(static_object<detail::dummy_constructor>::get());
- }
-
- template <typename V, typename D, typename P, typename B>
- std::pair<typename bidirectional_graph_archetype<V,D,P,B>::out_edge_iterator,
- typename bidirectional_graph_archetype<V,D,P,B>::out_edge_iterator>
- out_edges(typename bidirectional_graph_archetype<V,D,P,B>::vertex_descriptor,
- const bidirectional_graph_archetype<V,D,P,B>&)
- {
- typedef typename bidirectional_graph_archetype<V,D,P,B>::out_edge_iterator Iter;
- return std::make_pair(Iter(), Iter());
- }
-
- template <typename V, typename D, typename P, typename B>
- typename bidirectional_graph_archetype<V,D,P,B>::degree_size_type
- out_degree(typename bidirectional_graph_archetype<V,D,P,B>::vertex_descriptor,
- const bidirectional_graph_archetype<V,D,P,B>&)
- { return 0; }
- */
-
- template <typename V, typename D, typename P, typename B>
- std::pair<typename bidirectional_graph_archetype<V,D,P,B>::in_edge_iterator,
- typename bidirectional_graph_archetype<V,D,P,B>::in_edge_iterator>
- in_edges(typename bidirectional_graph_archetype<V,D,P,B>::vertex_descriptor,
- const bidirectional_graph_archetype<V,D,P,B>&)
- {
- typedef typename incidence_graph_archetype<V,D,P,B>::in_edge_iterator Iter;
- return std::make_pair(Iter(), Iter());
- }
-
- template <typename V, typename D, typename P, typename B>
- typename bidirectional_graph_archetype<V,D,P,B>::degree_size_type
- in_degree(typename bidirectional_graph_archetype<V,D,P,B>::vertex_desriptior,
- const bidirectional_graph_archetype<V,D,P,B>&)
- {
- return 0;
- }
+ typedef Distance distance_type;
+ typedef Result result_type;
+ result_type operator ()(distance_type, const Graph&)
+ { return result_type(); }
+ };
 }
 
 #endif

Modified: sandbox/SOC/2007/graphs/libs/graph/test/concept/closeness_centrality_check.cpp
==============================================================================
--- sandbox/SOC/2007/graphs/libs/graph/test/concept/closeness_centrality_check.cpp (original)
+++ sandbox/SOC/2007/graphs/libs/graph/test/concept/closeness_centrality_check.cpp 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
@@ -29,12 +29,15 @@
         typedef writable_property_map_archetype<Vertex, float> CentralityMap;
         typedef readable_property_map_archetype<Vertex, size_t> DistanceMap;
         typedef readable_property_map_archetype<Vertex, DistanceMap> DistanceMatrix;
+ typedef distance_measure_archetype<Graph, size_t, float> Measure;
 
         Graph& g = static_object<Graph>::get();
         CentralityMap cm;
         DistanceMatrix dm;
+ Measure m;
 
         closeness_centrality(g, dm, cm);
+ closeness_centrality(g, dm, cm, m);
     }
 
     return 0;

Modified: sandbox/SOC/2007/graphs/libs/graph/test/concept/degree_centrality_check.cpp
==============================================================================
--- sandbox/SOC/2007/graphs/libs/graph/test/concept/degree_centrality_check.cpp (original)
+++ sandbox/SOC/2007/graphs/libs/graph/test/concept/degree_centrality_check.cpp 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
@@ -39,6 +39,7 @@
     // how to test this. Even If I build one, it won't compile very
     // easily.
     {
+ /*
         typedef descriptor_archetype Vertex;
         typedef bidirectional_graph_archetype<
                 Vertex,
@@ -52,6 +53,7 @@
                 BidirectionalGraph
> graph_type;
         typedef read_write_property_map_archetype<Vertex, size_t> CentralityMap;
+ */
 
         // These don't actually work - apparently, it's not very easy
         // to generate archetypes across concept hierarchies and have

Added: sandbox/SOC/2007/graphs/libs/graph/test/concept/mean_geodesic_check.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/graphs/libs/graph/test/concept/mean_geodesic_check.cpp 2007-08-14 08:16:15 EDT (Tue, 14 Aug 2007)
@@ -0,0 +1,44 @@
+// (C) Copyright Andrew Sutton 2007
+//
+// Use, modification and distribution are subject to the
+// Boost Software License, Version 1.0 (See accompanying file
+// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+#include "archetypes.hpp"
+#include <boost/graph/geodesic_distance.hpp>
+
+using namespace std;
+using namespace boost;
+
+int
+main(int argc, char *argv[])
+{
+ {
+ typedef descriptor_archetype Vertex;
+ typedef incidence_graph_archetype<
+ Vertex,
+ undirected_tag,
+ allow_parallel_edge_tag
+ > IncidenceGraph;
+ typedef vertex_list_graph_archetype<
+ Vertex,
+ undirected_tag,
+ allow_parallel_edge_tag,
+ IncidenceGraph
+ > Graph;
+ typedef writable_property_map_archetype<Vertex, float> CentralityMap;
+ typedef readable_property_map_archetype<Vertex, size_t> DistanceMap;
+ typedef readable_property_map_archetype<Vertex, DistanceMap> DistanceMatrix;
+ typedef distance_measure_archetype<Graph, size_t, float> Measure;
+
+ Graph& g = static_object<Graph>::get();
+ CentralityMap cm;
+ DistanceMatrix dm;
+ Measure m;
+
+ mean_geodesic(g, dm, cm);
+ mean_geodesic(g, dm, cm, m);
+ }
+
+ return 0;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk