|
Boost-Commit : |
From: dgregor_at_[hidden]
Date: 2008-02-07 16:29:02
Author: dgregor
Date: 2008-02-07 16:29:02 EST (Thu, 07 Feb 2008)
New Revision: 43167
URL: http://svn.boost.org/trac/boost/changeset/43167
Log:
Merge fix for add_vertex in compressed_sparse_row with properties
Text files modified:
branches/release/boost/graph/compressed_sparse_row_graph.hpp | 2 ++
branches/release/boost/graph/detail/indexed_properties.hpp | 3 +++
branches/release/libs/graph/test/csr_graph_test.cpp | 11 ++++++++++-
3 files changed, 15 insertions(+), 1 deletions(-)
Modified: branches/release/boost/graph/compressed_sparse_row_graph.hpp
==============================================================================
--- branches/release/boost/graph/compressed_sparse_row_graph.hpp (original)
+++ branches/release/boost/graph/compressed_sparse_row_graph.hpp 2008-02-07 16:29:02 EST (Thu, 07 Feb 2008)
@@ -347,6 +347,7 @@
add_vertex(BOOST_CSR_GRAPH_TYPE& g) {
Vertex old_num_verts_plus_one = g.m_rowstart.size();
g.m_rowstart.push_back(EdgeIndex(0));
+ g.vertex_properties().resize(num_vertices(g));
return old_num_verts_plus_one - 1;
}
@@ -355,6 +356,7 @@
add_vertices(typename BOOST_CSR_GRAPH_TYPE::vertices_size_type count, BOOST_CSR_GRAPH_TYPE& g) {
Vertex old_num_verts_plus_one = g.m_rowstart.size();
g.m_rowstart.resize(old_num_verts_plus_one + count, EdgeIndex(0));
+ g.vertex_properties().resize(num_vertices(g));
return old_num_verts_plus_one - 1;
}
Modified: branches/release/boost/graph/detail/indexed_properties.hpp
==============================================================================
--- branches/release/boost/graph/detail/indexed_properties.hpp (original)
+++ branches/release/boost/graph/detail/indexed_properties.hpp 2008-02-07 16:29:02 EST (Thu, 07 Feb 2008)
@@ -49,6 +49,7 @@
// Initialize with n default-constructed property values
indexed_vertex_properties(std::size_t n) : m_vertex_properties(n) { }
+public:
// Resize the properties vector
void resize(std::size_t n)
{
@@ -92,6 +93,8 @@
// All operations do nothing.
indexed_vertex_properties() { }
indexed_vertex_properties(std::size_t) { }
+
+public:
void resize(std::size_t) { }
void reserve(std::size_t) { }
};
Modified: branches/release/libs/graph/test/csr_graph_test.cpp
==============================================================================
--- branches/release/libs/graph/test/csr_graph_test.cpp (original)
+++ branches/release/libs/graph/test/csr_graph_test.cpp 2008-02-07 16:29:02 EST (Thu, 07 Feb 2008)
@@ -38,7 +38,13 @@
typedef boost::adjacency_list<> GraphT;
typedef boost::erdos_renyi_iterator<boost::minstd_rand, GraphT> ERGen;
-typedef boost::compressed_sparse_row_graph<> CSRGraphT;
+struct VertexData
+{
+ int index;
+};
+
+typedef boost::compressed_sparse_row_graph<boost::directedS, VertexData>
+ CSRGraphT;
template <class G1, class VI1, class G2, class VI2, class IsomorphismMap>
void assert_graphs_equal(const G1& g1, const VI1& vi1,
@@ -191,6 +197,9 @@
CSRGraphT g4;
BOOST_CHECK(num_vertices(g4) == 0);
std::size_t first_vert = add_vertices(num_vertices(g3), g4);
+ BGL_FORALL_VERTICES(v, g4, CSRGraphT)
+ g4[v].index = v;
+
BOOST_CHECK(first_vert == 0);
BOOST_CHECK(num_vertices(g4) == num_vertices(g3));
CSRGraphT::edge_iterator ei, ei_end;
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