Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56473 - trunk/boost/graph/detail
From: jewillco_at_[hidden]
Date: 2009-09-29 12:33:36


Author: jewillco
Date: 2009-09-29 12:33:35 EDT (Tue, 29 Sep 2009)
New Revision: 56473
URL: http://svn.boost.org/trac/boost/changeset/56473

Log:
Another attempt at a CSR edges() fix
Text files modified:
   trunk/boost/graph/detail/compressed_sparse_row_struct.hpp | 17 ++++++++++-------
   1 files changed, 10 insertions(+), 7 deletions(-)

Modified: trunk/boost/graph/detail/compressed_sparse_row_struct.hpp
==============================================================================
--- trunk/boost/graph/detail/compressed_sparse_row_struct.hpp (original)
+++ trunk/boost/graph/detail/compressed_sparse_row_struct.hpp 2009-09-29 12:33:35 EDT (Tue, 29 Sep 2009)
@@ -476,13 +476,15 @@
     typedef typename CSRGraph::edges_size_type EdgeIndex;
 
    public:
- csr_edge_iterator() : rowstart_array(0), current_edge(), end_of_this_vertex(0) {}
+ csr_edge_iterator() : rowstart_array(0), current_edge(), end_of_this_vertex(0), total_num_edges(0) {}
 
     csr_edge_iterator(const CSRGraph& graph,
                       edge_descriptor current_edge,
                       EdgeIndex end_of_this_vertex)
- : rowstart_array(&graph.m_forward.m_rowstart), current_edge(current_edge),
- end_of_this_vertex(end_of_this_vertex) {}
+ : rowstart_array(&graph.m_forward.m_rowstart[0]),
+ current_edge(current_edge),
+ end_of_this_vertex(end_of_this_vertex),
+ total_num_edges(num_edges(graph)) {}
 
    public: // See above
     friend class boost::iterator_core_access;
@@ -495,16 +497,17 @@
 
     void increment() {
       ++current_edge.idx;
- while (current_edge.idx == end_of_this_vertex &&
- current_edge.src + 1 < rowstart_array->size()) {
+ if (current_edge.idx == total_num_edges) return;
+ while (current_edge.idx == end_of_this_vertex) {
         ++current_edge.src;
- end_of_this_vertex = (*rowstart_array)[current_edge.src + 1];
+ end_of_this_vertex = rowstart_array[current_edge.src + 1];
       }
     }
 
- const std::vector<EdgeIndex>* rowstart_array;
+ const EdgeIndex* rowstart_array;
     edge_descriptor current_edge;
     EdgeIndex end_of_this_vertex;
+ EdgeIndex total_num_edges;
   };
 
   // Only for bidirectional graphs


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