Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55001 - in sandbox/SOC/2009/function_graph: boost/function_graph libs/test
From: mlopez7_at_[hidden]
Date: 2009-07-17 14:54:46


Author: lopezeant
Date: 2009-07-17 14:54:46 EDT (Fri, 17 Jul 2009)
New Revision: 55001
URL: http://svn.boost.org/trac/boost/changeset/55001

Log:
Adjacency iterator fixed.
Text files modified:
   sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp | 13 +++++++++-
   sandbox/SOC/2009/function_graph/libs/test/test3.cpp | 46 ++++++++++++++++++++++++++++++++-------
   2 files changed, 48 insertions(+), 11 deletions(-)

Modified: sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp
==============================================================================
--- sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp (original)
+++ sandbox/SOC/2009/function_graph/boost/function_graph/function_graph.hpp 2009-07-17 14:54:46 EDT (Fri, 17 Jul 2009)
@@ -344,7 +344,9 @@
 template<typename Result, typename Vertex, typename Range>
 typename FUNC_GRAPH::degree_size_type
 degree(typename FUNC_GRAPH::vertex_descriptor const& v, FUNC_GRAPH const& g)
-{ return in_degree(v, g) + out_degree(v, g); }
+{
+ return in_degree(v, g) + out_degree(v, g);
+}
 
 
 
@@ -632,6 +634,7 @@
                                       vertex_descriptor const& vertex)
         : g_(g), vertex_(vertex), i_at_(begin(g_.range_)), in_edge_check_(true)
     {
+ const vertex_iterator i_begin = begin(g_.range_);
         const vertex_iterator i_end = end(g_.range_);
 
         while(i_at_ != i_end && !edge(*i_at_, vertex_, g_).second)
@@ -671,7 +674,13 @@
             do {
                 ++i_at_;
             } while(i_at_ != i_end && !edge(*i_at_, vertex_, g_).second);
- if(i_at_ == i_end) in_edge_check_ = false;
+ if(i_at_ == i_end)
+ {
+ in_edge_check_ = false;
+ i_at_ = begin(g_.range_);
+ if(edge(vertex_, *i_at_, g_).second)
+ { return *this; }
+ }
         }
         if(!in_edge_check_)
         {

Modified: sandbox/SOC/2009/function_graph/libs/test/test3.cpp
==============================================================================
--- sandbox/SOC/2009/function_graph/libs/test/test3.cpp (original)
+++ sandbox/SOC/2009/function_graph/libs/test/test3.cpp 2009-07-17 14:54:46 EDT (Fri, 17 Jul 2009)
@@ -28,7 +28,7 @@
 
 #define META_ASSERT(x) BOOST_ASSERT(x::value)
 
-namespace test3 {
+namespace t3 {
 // print an edge
 template<typename Graph>
 void print_edge(typename Graph::edge_descriptor const& e, Graph const& g)
@@ -46,7 +46,7 @@
 int main()
 {
     ////////
- // Data for graph
+ // Data for graphh
     long arr[8] = {56233, 572, -7851, 956242, -2, 893437, 63, 4474443};
     std::vector<long> numbers(arr, arr + 8);
 
@@ -84,6 +84,14 @@
                 weighted_graph::edge_iterator,
                 weighted_graph::edge_iterator
> edge_wght_range;
+ typedef std::pair<
+ boolean_graph::adjacency_iterator,
+ boolean_graph::adjacency_iterator
+ > adjacency_bool_range;
+ typedef std::pair<
+ weighted_graph::adjacency_iterator,
+ weighted_graph::adjacency_iterator
+ > adjacency_wght_range;
 
 
 
@@ -141,7 +149,7 @@
     unsigned int in_edges_count = 0;
     while(in_edges_bool.first != in_edges_bool.second)
     {
- test3::print_edge(*in_edges_bool.first, booleanGraph);
+ t3::print_edge(*in_edges_bool.first, booleanGraph);
         ++in_edges_bool.first;
         ++in_edges_count;
     }
@@ -165,6 +173,8 @@
 
     ////////
     // Check out edges
+ std::cout << "\n\n////Out Edges Check////\n\n";
+
     ++++++aVertex; // aVertex now holds -2
      out_edge_bool_range out_edges_bool = boost::out_edges(*aVertex,
                                                            booleanGraph);
@@ -173,10 +183,11 @@
     unsigned int out_edges_count = 0;
     while(out_edges_bool.first != out_edges_bool.second)
     {
- test3::print_edge(*out_edges_bool.first, booleanGraph);
+ t3::print_edge(*out_edges_bool.first, booleanGraph);
         ++out_edges_bool.first;
         ++out_edges_count;
     }
+ std::cerr << "\n\nout_edges_count : " << out_edges_count << "\n";
     assert(out_edges_count == out_degree(*aVertex, booleanGraph));
 
     out_edge_wght_range out_edges_wght = boost::out_edges(*aVertex,
@@ -202,11 +213,13 @@
 
     ////////
     // Check edges
+ std::cout << "\n\n////Edges Check////\n\n";
+
     edge_bool_range edges_bool = boost::edges(booleanGraph);
     unsigned int edges_count = 0;
     while(edges_bool.first != edges_bool.second)
     {
- //test3::print_edge_alt(*edges_bool.first, booleanGraph);
+ t3::print_edge_alt(*edges_bool.first, booleanGraph);
         ++edges_bool.first;
         ++edges_count; //TEMP: is 4
     }
@@ -216,18 +229,33 @@
     edges_count = 0;
     while(edges_wght.first != edges_wght.second)
     {
- test3::print_edge_alt(*edges_wght.first, weightedGraph);
+ t3::print_edge_alt(*edges_wght.first, weightedGraph);
         ++edges_wght.first;
         ++edges_count;
     }
- // Since this checks all possible pairs, the number of edges = 8 * 8 = 64
- assert(edges_count == num_edges(weightedGraph));
+ // Since this is all pairings of all vertices, num_edges = 8*8 = 64
+ assert(edges_count == num_edges(weightedGraph) && edges_count == 64);
 
 
 
     ////////
     // Check adjacent edges
- ++++aVertex;
+ std::cout << "\n\n////Adjacency Check////\n\n";
+
+ ++++aVertex; // vertex is now 63
+ adjacency_bool_range adjacent_bool =
+ boost::adjacent_vertices(*aVertex, booleanGraph);
+ unsigned int adjacent_vertices_count = 0;
+ while(adjacent_bool.first != adjacent_bool.second)
+ {
+ if(adjacent_bool.first.in_edge_check_)
+ std::cout << "(" << *adjacent_bool.first << ", " << *aVertex << ")\n";
+ else
+ std::cout << "(" << *aVertex << ", " << *adjacent_bool.first << ")\n";
+ ++adjacent_bool.first;
+ ++adjacent_vertices_count;
+ }
+ assert(adjacent_vertices_count == degree(*aVertex, booleanGraph));
 
     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