|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75891 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2011-12-11 02:19:20
Author: jewillco
Date: 2011-12-11 02:19:19 EST (Sun, 11 Dec 2011)
New Revision: 75891
URL: http://svn.boost.org/trac/boost/changeset/75891
Log:
Fixed copying of reverse_graphs to compensate for new reverse_edge_descriptor class
Text files modified:
trunk/boost/graph/copy.hpp | 25 ++++++++++++++++++++++---
trunk/boost/graph/reverse_graph.hpp | 27 +++++++++++++++++++++++----
2 files changed, 45 insertions(+), 7 deletions(-)
Modified: trunk/boost/graph/copy.hpp
==============================================================================
--- trunk/boost/graph/copy.hpp (original)
+++ trunk/boost/graph/copy.hpp 2011-12-11 02:19:19 EST (Sun, 11 Dec 2011)
@@ -44,6 +44,7 @@
#include <boost/config.hpp>
#include <vector>
#include <boost/graph/graph_traits.hpp>
+#include <boost/graph/reverse_graph.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/named_function_params.hpp>
#include <boost/graph/breadth_first_search.hpp>
@@ -53,6 +54,21 @@
namespace detail {
+ // Hack to make transpose_graph work with the same interface as before
+ template <typename Desc>
+ struct remove_reverse_edge_descriptor {
+ typedef Desc type;
+ static Desc convert(const Desc& d) {return d;}
+ };
+
+ template <typename Desc>
+ struct remove_reverse_edge_descriptor<reverse_graph_edge_descriptor<Desc> > {
+ typedef Desc type;
+ static Desc convert(const reverse_graph_edge_descriptor<Desc>& d) {
+ return d.underlying_desc;
+ }
+ };
+
// Default edge and vertex property copiers
template <typename Graph1, typename Graph2>
@@ -112,6 +128,7 @@
CopyVertex copy_vertex, CopyEdge copy_edge,
Orig2CopyVertexIndexMap orig2copy, IndexMap)
{
+ typedef remove_reverse_edge_descriptor<typename graph_traits<Graph>::edge_descriptor> cvt;
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
typename graph_traits<MutableGraph>::vertex_descriptor
@@ -126,7 +143,7 @@
boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)),
get(orig2copy, target(*ei, g_in)),
g_out);
- copy_edge(*ei, new_e);
+ copy_edge(cvt::convert(*ei), new_e);
}
}
};
@@ -141,6 +158,7 @@
CopyVertex copy_vertex, CopyEdge copy_edge,
Orig2CopyVertexIndexMap orig2copy, IndexMap)
{
+ typedef remove_reverse_edge_descriptor<typename graph_traits<Graph>::edge_descriptor> cvt;
typename graph_traits<Graph>::vertex_iterator vi, vi_end;
for (boost::tie(vi, vi_end) = vertices(g_in); vi != vi_end; ++vi) {
typename graph_traits<MutableGraph>::vertex_descriptor
@@ -156,7 +174,7 @@
boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei, g_in)),
get(orig2copy, target(*ei, g_in)),
g_out);
- copy_edge(*ei, new_e);
+ copy_edge(cvt::convert(*ei), new_e);
}
}
}
@@ -173,6 +191,7 @@
Orig2CopyVertexIndexMap orig2copy,
IndexMap index_map)
{
+ typedef remove_reverse_edge_descriptor<typename graph_traits<Graph>::edge_descriptor> cvt;
typedef color_traits<default_color_type> Color;
std::vector<default_color_type>
color(num_vertices(g_in), Color::white());
@@ -192,7 +211,7 @@
boost::tie(new_e, inserted) = add_edge(get(orig2copy, source(*ei,g_in)),
get(orig2copy, target(*ei,g_in)),
g_out);
- copy_edge(*ei, new_e);
+ copy_edge(cvt::convert(*ei), new_e);
}
}
color[get(index_map, *vi)] = Color::black();
Modified: trunk/boost/graph/reverse_graph.hpp
==============================================================================
--- trunk/boost/graph/reverse_graph.hpp (original)
+++ trunk/boost/graph/reverse_graph.hpp 2011-12-11 02:19:19 EST (Sun, 11 Dec 2011)
@@ -28,6 +28,7 @@
class reverse_graph_edge_descriptor {
public:
EdgeDesc underlying_desc;
+ typedef EdgeDesc base_descriptor_type;
public:
explicit reverse_graph_edge_descriptor(const EdgeDesc& underlying_desc = EdgeDesc())
@@ -70,6 +71,18 @@
make_transform_iterator(ip.second, reverse_graph_edge_descriptor_maker<EdgeDesc>()));
}
+ // Get the underlying descriptor from a vertex or edge descriptor
+ template <typename Desc>
+ struct get_underlying_descriptor_from_reverse_descriptor {
+ typedef Desc type;
+ static Desc convert(const Desc& d) {return d;}
+ };
+ template <typename Desc>
+ struct get_underlying_descriptor_from_reverse_descriptor<reverse_graph_edge_descriptor<Desc> > {
+ typedef Desc type;
+ static Desc convert(const reverse_graph_edge_descriptor<Desc>& d) {return d.underlying_desc;}
+ };
+
template <bool isEdgeList> struct choose_rev_edge_iter { };
template <> struct choose_rev_edge_iter<true> {
template <class G> struct bind_ {
@@ -129,14 +142,20 @@
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
// Bundled properties support
template<typename Descriptor>
- typename graph::detail::bundled_result<BidirectionalGraph, Descriptor>::type&
+ typename graph::detail::bundled_result<
+ BidirectionalGraph,
+ typename detail::get_underlying_descriptor_from_reverse_descriptor<Descriptor>::type
+ >::type&
operator[](Descriptor x)
- { return m_g[x]; }
+ { return detail::get_underlying_descriptor_from_reverse_descriptor<Descriptor>::convert(m_g[x]); }
template<typename Descriptor>
- typename graph::detail::bundled_result<BidirectionalGraph, Descriptor>::type const&
+ typename graph::detail::bundled_result<
+ BidirectionalGraph,
+ typename detail::get_underlying_descriptor_from_reverse_descriptor<Descriptor>::type
+ >::type const&
operator[](Descriptor x) const
- { return m_g[x]; }
+ { return detail::get_underlying_descriptor_from_reverse_descriptor<Descriptor>::convert(m_g[x]); }
#endif // BOOST_GRAPH_NO_BUNDLED_PROPERTIES
static vertex_descriptor null_vertex()
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