|
Boost-Commit : |
From: dgregor_at_[hidden]
Date: 2008-02-05 15:51:24
Author: dgregor
Date: 2008-02-05 15:51:23 EST (Tue, 05 Feb 2008)
New Revision: 43117
URL: http://svn.boost.org/trac/boost/changeset/43117
Log:
Fix add_vertex and add_vertices when the CSR graph has vertex properties
Text files modified:
trunk/boost/graph/compressed_sparse_row_graph.hpp | 2 ++
trunk/boost/graph/detail/indexed_properties.hpp | 3 +++
trunk/libs/graph/test/csr_graph_test.cpp | 11 ++++++++++-
3 files changed, 15 insertions(+), 1 deletions(-)
Modified: trunk/boost/graph/compressed_sparse_row_graph.hpp
==============================================================================
--- trunk/boost/graph/compressed_sparse_row_graph.hpp (original)
+++ trunk/boost/graph/compressed_sparse_row_graph.hpp 2008-02-05 15:51:23 EST (Tue, 05 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: trunk/boost/graph/detail/indexed_properties.hpp
==============================================================================
--- trunk/boost/graph/detail/indexed_properties.hpp (original)
+++ trunk/boost/graph/detail/indexed_properties.hpp 2008-02-05 15:51:23 EST (Tue, 05 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: trunk/libs/graph/test/csr_graph_test.cpp
==============================================================================
--- trunk/libs/graph/test/csr_graph_test.cpp (original)
+++ trunk/libs/graph/test/csr_graph_test.cpp 2008-02-05 15:51:23 EST (Tue, 05 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