2
0
mirror of https://github.com/boostorg/graph.git synced 2026-02-26 16:52:12 +00:00

Merged Boost.Graph changes from trunk for 1.53

[SVN r82061]
This commit is contained in:
Jeremiah Willcock
2012-12-17 23:59:46 +00:00
parent 3419d42acc
commit 22b521ecf4
41 changed files with 2795 additions and 150 deletions

View File

@@ -188,6 +188,7 @@ namespace boost {
} // namespace detail
template <typename Selector> struct is_distributed_selector: mpl::false_ {};
//===========================================================================

View File

@@ -22,9 +22,12 @@
#include <boost/graph/relax.hpp>
#include <boost/graph/exception.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/detail/d_ary_heap.hpp>
#include <boost/graph/property_maps/constant_property_map.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/property_map/vector_property_map.hpp>
#include <boost/property_map/function_property_map.hpp>
#include <boost/concept/assert.hpp>
namespace boost {
@@ -159,8 +162,9 @@ namespace boost {
template <class Edge, class Graph>
void tree_edge(Edge e, const Graph& g) {
using boost::get;
m_decreased = relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
bool m_decreased =
relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
if(m_decreased) {
m_vis.edge_relaxed(e, g);
@@ -175,8 +179,9 @@ namespace boost {
template <class Edge, class Graph>
void gray_target(Edge e, const Graph& g) {
using boost::get;
m_decreased = relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
bool m_decreased =
relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
if(m_decreased) {
put(m_cost, target(e, g),
@@ -192,8 +197,9 @@ namespace boost {
template <class Edge, class Graph>
void black_target(Edge e, const Graph& g) {
using boost::get;
m_decreased = relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
bool m_decreased =
relax(e, g, m_weight, m_predecessor, m_distance,
m_combine, m_compare);
if(m_decreased) {
m_vis.edge_relaxed(e, g);
@@ -219,7 +225,6 @@ namespace boost {
ColorMap m_color;
BinaryFunction m_combine;
BinaryPredicate m_compare;
bool m_decreased;
C m_zero;
};
@@ -263,6 +268,77 @@ namespace boost {
breadth_first_visit(g, s, Q, bfs_vis, color);
}
namespace graph_detail {
template <typename A, typename B>
struct select1st {
typedef std::pair<A, B> argument_type;
typedef A result_type;
A operator()(const std::pair<A, B>& p) const {return p.first;}
};
}
template <typename VertexListGraph, typename AStarHeuristic,
typename AStarVisitor, typename PredecessorMap,
typename CostMap, typename DistanceMap,
typename WeightMap,
typename CompareFunction, typename CombineFunction,
typename CostInf, typename CostZero>
inline void
astar_search_no_init_tree
(const VertexListGraph &g,
typename graph_traits<VertexListGraph>::vertex_descriptor s,
AStarHeuristic h, AStarVisitor vis,
PredecessorMap predecessor, CostMap cost,
DistanceMap distance, WeightMap weight,
CompareFunction compare, CombineFunction combine,
CostInf /*inf*/, CostZero zero)
{
typedef typename graph_traits<VertexListGraph>::vertex_descriptor
Vertex;
typedef typename property_traits<DistanceMap>::value_type Distance;
typedef d_ary_heap_indirect<
std::pair<Distance, Vertex>,
4,
null_property_map<std::pair<Distance, Vertex>, std::size_t>,
function_property_map<graph_detail::select1st<Distance, Vertex>, std::pair<Distance, Vertex> >,
CompareFunction>
MutableQueue;
MutableQueue Q(
make_function_property_map<std::pair<Distance, Vertex> >(graph_detail::select1st<Distance, Vertex>()),
null_property_map<std::pair<Distance, Vertex>, std::size_t>(),
compare);
vis.discover_vertex(s, g);
Q.push(std::make_pair(get(cost, s), s));
while (!Q.empty()) {
Vertex v;
Distance v_rank;
boost::tie(v_rank, v) = Q.top();
Q.pop();
vis.examine_vertex(v, g);
BGL_FORALL_OUTEDGES_T(v, e, g, VertexListGraph) {
Vertex w = target(e, g);
vis.examine_edge(e, g);
Distance e_weight = get(weight, e);
if (compare(e_weight, zero))
BOOST_THROW_EXCEPTION(negative_edge());
bool decreased =
relax(e, g, weight, predecessor, distance,
combine, compare);
Distance w_d = combine(get(distance, v), e_weight);
if (decreased) {
vis.edge_relaxed(e, g);
Distance w_rank = combine(get(distance, w), h(w));
put(cost, w, w_rank);
vis.discover_vertex(w, g);
Q.push(std::make_pair(w_rank, w));
} else {
vis.edge_not_relaxed(e, g);
}
}
vis.finish_vertex(v, g);
}
}
// Non-named parameter interface
template <typename VertexListGraph, typename AStarHeuristic,
@@ -303,6 +379,40 @@ namespace boost {
}
// Non-named parameter interface
template <typename VertexListGraph, typename AStarHeuristic,
typename AStarVisitor, typename PredecessorMap,
typename CostMap, typename DistanceMap,
typename WeightMap,
typename CompareFunction, typename CombineFunction,
typename CostInf, typename CostZero>
inline void
astar_search_tree
(const VertexListGraph &g,
typename graph_traits<VertexListGraph>::vertex_descriptor s,
AStarHeuristic h, AStarVisitor vis,
PredecessorMap predecessor, CostMap cost,
DistanceMap distance, WeightMap weight,
CompareFunction compare, CombineFunction combine,
CostInf inf, CostZero zero)
{
typename graph_traits<VertexListGraph>::vertex_iterator ui, ui_end;
for (boost::tie(ui, ui_end) = vertices(g); ui != ui_end; ++ui) {
put(distance, *ui, inf);
put(cost, *ui, inf);
put(predecessor, *ui, *ui);
vis.initialize_vertex(*ui, g);
}
put(distance, s, zero);
put(cost, s, h(s));
astar_search_no_init_tree
(g, s, h, vis, predecessor, cost, distance, weight,
compare, combine, inf, zero);
}
// Named parameter interfaces
template <typename VertexListGraph,
typename AStarHeuristic,
@@ -345,6 +455,46 @@ namespace boost {
arg_pack[_distance_zero | D()]);
}
// Named parameter interfaces
template <typename VertexListGraph,
typename AStarHeuristic,
typename P, typename T, typename R>
void
astar_search_tree
(const VertexListGraph &g,
typename graph_traits<VertexListGraph>::vertex_descriptor s,
AStarHeuristic h, const bgl_named_params<P, T, R>& params)
{
using namespace boost::graph::keywords;
typedef bgl_named_params<P, T, R> params_type;
BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
// Distance type is the value type of the distance map if there is one,
// otherwise the value type of the weight map.
typedef
typename detail::override_const_property_result<
arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
weight_map_type;
typedef typename boost::property_traits<weight_map_type>::value_type W;
typedef
typename detail::map_maker<VertexListGraph, arg_pack_type, tag::distance_map, W>::map_type
distance_map_type;
typedef typename boost::property_traits<distance_map_type>::value_type D;
const D inf = arg_pack[_distance_inf | (std::numeric_limits<D>::max)()];
astar_search_tree
(g, s, h,
arg_pack[_visitor | make_astar_visitor(null_visitor())],
arg_pack[_predecessor_map | dummy_property_map()],
detail::make_property_map_from_arg_pack_gen<tag::rank_map, D>(D())(g, arg_pack),
detail::make_property_map_from_arg_pack_gen<tag::distance_map, W>(W())(g, arg_pack),
detail::override_const_property(arg_pack, _weight_map, g, edge_weight),
arg_pack[_distance_compare | std::less<D>()],
arg_pack[_distance_combine | closed_plus<D>(inf)],
inf,
arg_pack[_distance_zero | D()]);
}
template <typename VertexListGraph,
typename AStarHeuristic,
typename P, typename T, typename R>
@@ -378,6 +528,37 @@ namespace boost {
arg_pack[_distance_zero | D()]);
}
template <typename VertexListGraph,
typename AStarHeuristic,
typename P, typename T, typename R>
void
astar_search_no_init_tree
(const VertexListGraph &g,
typename graph_traits<VertexListGraph>::vertex_descriptor s,
AStarHeuristic h, const bgl_named_params<P, T, R>& params)
{
using namespace boost::graph::keywords;
typedef bgl_named_params<P, T, R> params_type;
BOOST_GRAPH_DECLARE_CONVERTED_PARAMETERS(params_type, params)
typedef
typename detail::override_const_property_result<
arg_pack_type, tag::weight_map, edge_weight_t, VertexListGraph>::type
weight_map_type;
typedef typename boost::property_traits<weight_map_type>::value_type D;
const D inf = arg_pack[_distance_inf | (std::numeric_limits<D>::max)()];
astar_search_no_init_tree
(g, s, h,
arg_pack[_visitor | make_astar_visitor(null_visitor())],
arg_pack[_predecessor_map | dummy_property_map()],
detail::make_property_map_from_arg_pack_gen<tag::rank_map, D>(D())(g, arg_pack),
detail::make_property_map_from_arg_pack_gen<tag::distance_map, D>(D())(g, arg_pack),
detail::override_const_property(arg_pack, _weight_map, g, edge_weight),
arg_pack[_distance_compare | std::less<D>()],
arg_pack[_distance_combine | closed_plus<D>(inf)],
inf,
arg_pack[_distance_zero | D()]);
}
} // namespace boost
#endif // BOOST_GRAPH_ASTAR_SEARCH_HPP

View File

@@ -442,11 +442,11 @@ class bk_max_flow {
for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){
edge_descriptor in_edge = get(m_rev_edge_map, *ei);
vertex_descriptor other_node = source(in_edge, m_g);
if(get_tree(other_node) == tColorTraits::black() && has_parent(other_node)){
if(get_tree(other_node) == tColorTraits::black() && other_node != m_source){
if(get(m_res_cap_map, in_edge) > 0){
add_active_node(other_node);
}
if(source(get_edge_to_parent(other_node), m_g) == current_node){
if(has_parent(other_node) && source(get_edge_to_parent(other_node), m_g) == current_node){
//we are the parent of that node
//it has to find a new parent, too
set_no_parent(other_node);
@@ -483,11 +483,11 @@ class bk_max_flow {
for(boost::tie(ei, e_end) = out_edges(current_node, m_g); ei != e_end; ++ei){
const edge_descriptor out_edge = *ei;
const vertex_descriptor other_node = target(out_edge, m_g);
if(get_tree(other_node) == tColorTraits::white() && has_parent(other_node)){
if(get_tree(other_node) == tColorTraits::white() && other_node != m_sink){
if(get(m_res_cap_map, out_edge) > 0){
add_active_node(other_node);
}
if(target(get_edge_to_parent(other_node), m_g) == current_node){
if(has_parent(other_node) && target(get_edge_to_parent(other_node), m_g) == current_node){
//we were it's parent, so it has to find a new one, too
set_no_parent(other_node);
m_child_orphans.push(other_node);
@@ -526,6 +526,9 @@ class bk_max_flow {
inline void add_active_node(vertex_descriptor v){
BOOST_ASSERT(get_tree(v) != tColorTraits::gray());
if(get(m_in_active_list_map, v)){
if (m_last_grow_vertex == v) {
m_last_grow_vertex = graph_traits<Graph>::null_vertex();
}
return;
} else{
put(m_in_active_list_map, v, true);

View File

@@ -37,7 +37,9 @@
#include <boost/integer.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/mpl/if.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/graph/graph_selectors.hpp>
#include <boost/graph/detail/is_distributed_selector.hpp>
#include <boost/graph/properties.hpp>
#include <boost/static_assert.hpp>
#include <boost/functional/hash.hpp>
@@ -1322,8 +1324,9 @@ struct csr_property_map_helper<BOOST_CSR_GRAPH_TYPE, Tag, graph_property_tag> {
typedef transform_value_property_map<detail::lookup_one_property_f<const plist_type, Tag>, all_const_type> const_type;
};
// disable_if isn't truly necessary but required to avoid ambiguity with specializations below
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
struct property_map<BOOST_CSR_GRAPH_TYPE, Tag>:
struct property_map<BOOST_CSR_GRAPH_TYPE, Tag, typename disable_if<detail::is_distributed_selector<Vertex> >::type>:
csr_property_map_helper<
BOOST_CSR_GRAPH_TYPE,
Tag,
@@ -1370,35 +1373,35 @@ put(Tag tag,
}
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_index_t>
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_index_t, typename disable_if<detail::is_distributed_selector<Vertex> >::type>
{
typedef typed_identity_property_map<Vertex> type;
typedef type const_type;
};
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t>
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t, typename disable_if<detail::is_distributed_selector<Vertex> >::type>
{
typedef detail::csr_edge_index_map<Vertex, EdgeIndex> type;
typedef type const_type;
};
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_all_t>
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_all_t, typename disable_if<detail::is_distributed_selector<Vertex> >::type>
{
typedef typename BOOST_CSR_GRAPH_TYPE::inherited_vertex_properties::vertex_map_type type;
typedef typename BOOST_CSR_GRAPH_TYPE::inherited_vertex_properties::const_vertex_map_type const_type;
};
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_all_t>
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_all_t, typename disable_if<detail::is_distributed_selector<Vertex> >::type>
{
typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::edge_map_type type;
typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::const_edge_map_type const_type;
};
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
struct property_map<BOOST_CSR_GRAPH_TYPE, graph_all_t>
struct property_map<BOOST_CSR_GRAPH_TYPE, graph_all_t, typename disable_if<detail::is_distributed_selector<Vertex> >::type>
{
typedef boost::ref_property_map<BOOST_CSR_GRAPH_TYPE*, typename BOOST_CSR_GRAPH_TYPE::graph_property_type> type;
typedef boost::ref_property_map<BOOST_CSR_GRAPH_TYPE*, const typename BOOST_CSR_GRAPH_TYPE::graph_property_type> const_type;

View File

@@ -309,14 +309,16 @@ namespace boost {
public:
typedef Property property_type;
inline stored_ra_edge_iter() { }
inline stored_ra_edge_iter(Vertex v, Iter i = Iter(),
EdgeVec* edge_vec = 0)
inline explicit stored_ra_edge_iter(Vertex v) // Only used for comparisons
: stored_edge<Vertex>(v), m_i(0), m_vec(0){ }
inline stored_ra_edge_iter(Vertex v, Iter i, EdgeVec* edge_vec)
: stored_edge<Vertex>(v), m_i(i - edge_vec->begin()), m_vec(edge_vec){ }
inline Property& get_property() { return (*m_vec)[m_i].get_property(); }
inline Property& get_property() { BOOST_ASSERT ((m_vec != 0)); return (*m_vec)[m_i].get_property(); }
inline const Property& get_property() const {
BOOST_ASSERT ((m_vec != 0));
return (*m_vec)[m_i].get_property();
}
inline Iter get_iter() const { return m_vec->begin() + m_i; }
inline Iter get_iter() const { BOOST_ASSERT ((m_vec != 0)); return m_vec->begin() + m_i; }
protected:
std::size_t m_i;
EdgeVec* m_vec;

View File

@@ -126,18 +126,21 @@ namespace boost {
}
Value& top() {
BOOST_ASSERT (!this->empty());
return data[0];
}
const Value& top() const {
BOOST_ASSERT (!this->empty());
return data[0];
}
void pop() {
BOOST_ASSERT (!this->empty());
put(index_in_heap, data[0], (size_type)(-1));
if (data.size() != 1) {
data[0] = data.back();
put(index_in_heap, data[0], 0);
put(index_in_heap, data[0], (size_type)(0));
data.pop_back();
preserve_heap_property_down();
verify_heap();

View File

@@ -0,0 +1,26 @@
// Copyright 2012 The Trustees of Indiana University.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// Authors: Jeremiah Willcock
// Andrew Lumsdaine
// Selector to determine whether a selector is distributedS (can only be true
// if <boost/graph/distributed/selector.hpp> has been included) so that we can
// disable various sequential-graph-only traits specializations for distributed
// graphs.
#ifndef BOOST_GRAPH_DETAIL_IS_DISTRIBUTED_SELECTOR_HPP
#define BOOST_GRAPH_DETAIL_IS_DISTRIBUTED_SELECTOR_HPP
#include <boost/mpl/bool.hpp>
namespace boost {
namespace detail {
template <typename> struct is_distributed_selector: boost::mpl::false_ {};
}
}
#endif // BOOST_GRAPH_DETAIL_IS_DISTRIBUTED_SELECTOR_HPP

View File

@@ -218,9 +218,9 @@ namespace graph_detail {
#define LABELED_GRAPH_PARAMS typename G, typename L, typename S
#define LABELED_GRAPH labeled_graph<G,L,S>
// Specialize mutability traits for for the labeled graph.
// Specialize mutability traits for the labeled graph.
// This specialization depends on the mutability of the underlying graph type.
// If the underlying graph is fully mutable, this this is also fully mutable.
// If the underlying graph is fully mutable, this is also fully mutable.
// Otherwise, it's different.
template <LABELED_GRAPH_PARAMS>
struct graph_mutability_traits< LABELED_GRAPH > {

View File

@@ -113,16 +113,17 @@ namespace boost {
distance_weight_combine, distance_compare);
if (was_edge_relaxed) {
vertex_queue.update(neighbor_vertex);
visitor.edge_relaxed(current_edge, graph);
if (is_neighbor_undiscovered) {
visitor.discover_vertex(neighbor_vertex, graph);
vertex_queue.push(neighbor_vertex);
} else {
vertex_queue.update(neighbor_vertex);
}
} else {
visitor.edge_not_relaxed(current_edge, graph);
}
if (is_neighbor_undiscovered) {
visitor.discover_vertex(neighbor_vertex, graph);
vertex_queue.push(neighbor_vertex);
}
} // end out edge iteration
visitor.finish_vertex(min_vertex, graph);

View File

@@ -9,6 +9,10 @@
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/properties.hpp>
#include <boost/pending/property.hpp>
#include <boost/property_map/transform_value_property_map.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/if.hpp>
namespace boost
{
@@ -27,8 +31,8 @@ struct directed_graph_tag { };
*/
template <
typename VertexProp = no_property,
typename EdgeProp= no_property,
typename GraphProp= no_property>
typename EdgeProp = no_property,
typename GraphProp = no_property>
class directed_graph
{
public:
@@ -39,15 +43,14 @@ public:
typedef typename lookup_one_property<VertexProp, vertex_bundle_t>::type vertex_bundled;
typedef typename lookup_one_property<EdgeProp, edge_bundle_t>::type edge_bundled;
private:
// Wrap the user-specified properties with an index.
typedef property<vertex_index_t, unsigned, vertex_property_type> vertex_property;
typedef property<edge_index_t, unsigned, edge_property_type> edge_property;
public:
// Embed indices into the vertex type.
typedef property<vertex_index_t, unsigned, vertex_property_type> internal_vertex_property;
typedef property<edge_index_t, unsigned, edge_property_type> internal_edge_property;
public:
typedef adjacency_list<
listS, listS, bidirectionalS,
vertex_property, edge_property, GraphProp,
internal_vertex_property, internal_edge_property, GraphProp,
listS
> graph_type;
@@ -80,8 +83,8 @@ public:
typedef typename graph_type::edge_parallel_category edge_parallel_category;
typedef typename graph_type::traversal_category traversal_category;
typedef unsigned vertex_index_type;
typedef unsigned edge_index_type;
typedef std::size_t vertex_index_type;
typedef std::size_t edge_index_type;
directed_graph(GraphProp const& p = GraphProp())
: m_graph(p), m_num_vertices(0), m_num_edges(0), m_max_vertex_index(0)
@@ -137,6 +140,7 @@ public:
vertices_size_type num_vertices() const
{ return m_num_vertices; }
private:
// This helper function manages the attribution of vertex indices.
vertex_descriptor make_index(vertex_descriptor v) {
@@ -150,7 +154,7 @@ public:
{ return make_index(boost::add_vertex(m_graph)); }
vertex_descriptor add_vertex(vertex_property_type const& p)
{ return make_index(boost::add_vertex(vertex_property(0u, p), m_graph)); }
{ return make_index(boost::add_vertex(internal_vertex_property(0u, p), m_graph)); }
void clear_vertex(vertex_descriptor v)
{
@@ -186,7 +190,7 @@ public:
std::pair<edge_descriptor, bool>
add_edge(vertex_descriptor u, vertex_descriptor v, edge_property_type const& p)
{ return make_index(boost::add_edge(u, v, edge_property(0u, p), m_graph)); }
{ return make_index(boost::add_edge(u, v, internal_edge_property(0u, p), m_graph)); }
void remove_edge(vertex_descriptor u, vertex_descriptor v)
{
@@ -516,37 +520,32 @@ remove_in_edge_if(typename DIRECTED_GRAPH::vertex_descriptor v,
DIRECTED_GRAPH& g)
{ return remove_in_edge_if(v, pred, g.impl()); }
// Helper code for working with property maps
namespace detail
{
struct directed_graph_vertex_property_selector {
template <class DirectedGraph, class Property, class Tag>
struct bind_ {
typedef typename DirectedGraph::graph_type Graph;
typedef property_map<Graph, Tag> PropertyMap;
typedef typename PropertyMap::type type;
typedef typename PropertyMap::const_type const_type;
};
};
template <DIRECTED_GRAPH_PARAMS, typename Property>
struct property_map<DIRECTED_GRAPH, Property>: property_map<typename DIRECTED_GRAPH::graph_type, Property> {};
struct directed_graph_edge_property_selector {
template <class DirectedGraph, class Property, class Tag>
struct bind_ {
typedef typename DirectedGraph::graph_type Graph;
typedef property_map<Graph, Tag> PropertyMap;
typedef typename PropertyMap::type type;
typedef typename PropertyMap::const_type const_type;
};
};
}
template <DIRECTED_GRAPH_PARAMS>
struct property_map<DIRECTED_GRAPH, vertex_all_t> {
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename DIRECTED_GRAPH::graph_type, vertex_all_t>::const_type>
const_type;
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename DIRECTED_GRAPH::graph_type, vertex_all_t>::type>
type;
};
template <>
struct vertex_property_selector<directed_graph_tag>
{ typedef detail::directed_graph_vertex_property_selector type; };
template <>
struct edge_property_selector<directed_graph_tag>
{ typedef detail::directed_graph_edge_property_selector type; };
template <DIRECTED_GRAPH_PARAMS>
struct property_map<DIRECTED_GRAPH, edge_all_t> {
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename DIRECTED_GRAPH::graph_type, edge_all_t>::const_type>
const_type;
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename DIRECTED_GRAPH::graph_type, edge_all_t>::type>
type;
};
// PropertyGraph concepts
template <DIRECTED_GRAPH_PARAMS, typename Property>
@@ -559,6 +558,26 @@ inline typename property_map<DIRECTED_GRAPH, Property>::const_type
get(Property p, DIRECTED_GRAPH const& g)
{ return get(p, g.impl()); }
template <DIRECTED_GRAPH_PARAMS>
inline typename property_map<DIRECTED_GRAPH, vertex_all_t>::type
get(vertex_all_t, DIRECTED_GRAPH& g)
{ return typename property_map<DIRECTED_GRAPH, vertex_all_t>::type(detail::remove_first_property(), get(vertex_all, g.impl())); }
template <DIRECTED_GRAPH_PARAMS>
inline typename property_map<DIRECTED_GRAPH, vertex_all_t>::const_type
get(vertex_all_t, DIRECTED_GRAPH const& g)
{ return typename property_map<DIRECTED_GRAPH, vertex_all_t>::const_type(detail::remove_first_property(), get(vertex_all, g.impl())); }
template <DIRECTED_GRAPH_PARAMS>
inline typename property_map<DIRECTED_GRAPH, edge_all_t>::type
get(edge_all_t, DIRECTED_GRAPH& g)
{ return typename property_map<DIRECTED_GRAPH, edge_all_t>::type(detail::remove_first_property(), get(edge_all, g.impl())); }
template <DIRECTED_GRAPH_PARAMS>
inline typename property_map<DIRECTED_GRAPH, edge_all_t>::const_type
get(edge_all_t, DIRECTED_GRAPH const& g)
{ return typename property_map<DIRECTED_GRAPH, edge_all_t>::const_type(detail::remove_first_property(), get(edge_all, g.impl())); }
template <DIRECTED_GRAPH_PARAMS, typename Property, typename Key>
inline typename property_traits<
typename property_map<
@@ -568,10 +587,40 @@ inline typename property_traits<
get(Property p, DIRECTED_GRAPH const& g, Key const& k)
{ return get(p, g.impl(), k); }
template <DIRECTED_GRAPH_PARAMS, typename Key>
inline typename property_traits<
typename property_map<
typename DIRECTED_GRAPH::graph_type, vertex_all_t
>::const_type
>::value_type
get(vertex_all_t, DIRECTED_GRAPH const& g, Key const& k)
{ return get(vertex_all, g.impl(), k).m_base; }
template <DIRECTED_GRAPH_PARAMS, typename Key>
inline typename property_traits<
typename property_map<
typename DIRECTED_GRAPH::graph_type, edge_all_t
>::const_type
>::value_type
get(edge_all_t, DIRECTED_GRAPH const& g, Key const& k)
{ return get(edge_all, g.impl(), k).m_base; }
template <DIRECTED_GRAPH_PARAMS, typename Property, typename Key, typename Value>
inline void put(Property p, DIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(p, g.impl(), k, v); }
template <DIRECTED_GRAPH_PARAMS, typename Key, typename Value>
inline void put(vertex_all_t, DIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(vertex_all, g.impl(), k,
typename DIRECTED_GRAPH::internal_vertex_property(get(vertex_index, g.impl(), k), v));
}
template <DIRECTED_GRAPH_PARAMS, typename Key, typename Value>
inline void put(edge_all_t, DIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(edge_all, g.impl(), k,
typename DIRECTED_GRAPH::internal_vertex_property(get(edge_index, g.impl(), k), v));
}
template <DIRECTED_GRAPH_PARAMS, class Property>
typename graph_property<DIRECTED_GRAPH, Property>::type&
get_property(DIRECTED_GRAPH& g, Property p)

View File

@@ -20,6 +20,9 @@
#include <boost/graph/numeric_values.hpp>
#include <boost/graph/buffer_concepts.hpp>
#include <boost/concept_check.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/mpl/not.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/concept/assert.hpp>
@@ -55,12 +58,10 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
BOOST_concept(Graph,(G))
{
typedef typename graph_traits<G>::vertex_descriptor vertex_descriptor;
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
typedef typename graph_traits<G>::directed_category directed_category;
typedef typename graph_traits<G>::edge_parallel_category
edge_parallel_category;
typedef typename graph_traits<G>::traversal_category
traversal_category;
typedef typename graph_traits<G>::edge_parallel_category edge_parallel_category;
typedef typename graph_traits<G>::traversal_category traversal_category;
BOOST_CONCEPT_USAGE(Graph)
{
@@ -75,11 +76,12 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
: Graph<G>
{
typedef typename graph_traits<G>::edge_descriptor edge_descriptor;
typedef typename graph_traits<G>::out_edge_iterator
out_edge_iterator;
typedef typename graph_traits<G>::out_edge_iterator out_edge_iterator;
typedef typename graph_traits<G>::degree_size_type degree_size_type;
typedef typename graph_traits<G>::traversal_category traversal_category;
typedef typename graph_traits<G>::traversal_category
traversal_category;
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<out_edge_iterator, void> >::value));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<degree_size_type, void> >::value));
BOOST_CONCEPT_USAGE(IncidenceGraph) {
BOOST_CONCEPT_ASSERT((MultiPassInputIterator<out_edge_iterator>));
@@ -123,6 +125,8 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
bidirectional_graph_tag>));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<in_edge_iterator, void> >::value));
p = in_edges(v, g);
n = in_degree(v, g);
e = *p.first;
@@ -153,6 +157,8 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
adjacency_graph_tag>));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<adjacency_iterator, void> >::value));
p = adjacent_vertices(v, g);
v = *p.first;
const_constraints(g);
@@ -178,6 +184,9 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
vertex_list_graph_tag>));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<vertex_iterator, void> >::value));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<vertices_size_type, void> >::value));
#ifdef BOOST_VECTOR_AS_GRAPH_GRAPH_ADL_HACK
// dwa 2003/7/11 -- This clearly shouldn't be necessary, but if
// you want to use vector_as_graph, it is! I'm sure the graph
@@ -227,6 +236,9 @@ typename T::ThereReallyIsNoMemberByThisNameInT vertices(T const&);
BOOST_CONCEPT_ASSERT((Convertible<traversal_category,
edge_list_graph_tag>));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<edge_iterator, void> >::value));
BOOST_STATIC_ASSERT((boost::mpl::not_<boost::is_same<edges_size_type, void> >::value));
p = edges(g);
e = *p.first;
u = source(e, g);

View File

@@ -20,6 +20,7 @@
#include <boost/mpl/not.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/void.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
@@ -28,23 +29,47 @@
namespace boost {
namespace detail {
#define BOOST_GRAPH_MEMBER_OR_VOID(name) \
BOOST_MPL_HAS_XXX_TRAIT_DEF(name) \
template <typename T> struct BOOST_JOIN(get_member_, name) {typedef typename T::name type;}; \
template <typename T> struct BOOST_JOIN(get_opt_member_, name): \
boost::mpl::eval_if_c< \
BOOST_JOIN(has_, name)<T>::value, \
BOOST_JOIN(get_member_, name)<T>, \
boost::mpl::identity<void> > \
{};
BOOST_GRAPH_MEMBER_OR_VOID(adjacency_iterator)
BOOST_GRAPH_MEMBER_OR_VOID(out_edge_iterator)
BOOST_GRAPH_MEMBER_OR_VOID(in_edge_iterator)
BOOST_GRAPH_MEMBER_OR_VOID(vertex_iterator)
BOOST_GRAPH_MEMBER_OR_VOID(edge_iterator)
BOOST_GRAPH_MEMBER_OR_VOID(vertices_size_type)
BOOST_GRAPH_MEMBER_OR_VOID(edges_size_type)
BOOST_GRAPH_MEMBER_OR_VOID(degree_size_type)
}
template <typename G>
struct graph_traits {
#define BOOST_GRAPH_PULL_OPT_MEMBER(name) \
typedef typename detail::BOOST_JOIN(get_opt_member_, name)<G>::type name;
typedef typename G::vertex_descriptor vertex_descriptor;
typedef typename G::edge_descriptor edge_descriptor;
typedef typename G::adjacency_iterator adjacency_iterator;
typedef typename G::out_edge_iterator out_edge_iterator;
typedef typename G::in_edge_iterator in_edge_iterator;
typedef typename G::vertex_iterator vertex_iterator;
typedef typename G::edge_iterator edge_iterator;
BOOST_GRAPH_PULL_OPT_MEMBER(adjacency_iterator)
BOOST_GRAPH_PULL_OPT_MEMBER(out_edge_iterator)
BOOST_GRAPH_PULL_OPT_MEMBER(in_edge_iterator)
BOOST_GRAPH_PULL_OPT_MEMBER(vertex_iterator)
BOOST_GRAPH_PULL_OPT_MEMBER(edge_iterator)
typedef typename G::directed_category directed_category;
typedef typename G::edge_parallel_category edge_parallel_category;
typedef typename G::traversal_category traversal_category;
typedef typename G::vertices_size_type vertices_size_type;
typedef typename G::edges_size_type edges_size_type;
typedef typename G::degree_size_type degree_size_type;
BOOST_GRAPH_PULL_OPT_MEMBER(vertices_size_type)
BOOST_GRAPH_PULL_OPT_MEMBER(edges_size_type)
BOOST_GRAPH_PULL_OPT_MEMBER(degree_size_type)
#undef BOOST_GRAPH_PULL_OPT_MEMBER
static inline vertex_descriptor null_vertex();
};

View File

@@ -204,14 +204,14 @@ template<typename MutableGraph>
const char* mutate_graph_impl<MutableGraph>::m_type_names[] = {"boolean", "int", "long", "float", "double", "string"};
void BOOST_GRAPH_DECL
read_graphml(std::istream& in, mutate_graph& g);
read_graphml(std::istream& in, mutate_graph& g, size_t desired_idx);
template<typename MutableGraph>
void
read_graphml(std::istream& in, MutableGraph& g, dynamic_properties& dp)
read_graphml(std::istream& in, MutableGraph& g, dynamic_properties& dp, size_t desired_idx = 0)
{
mutate_graph_impl<MutableGraph> mg(g,dp);
read_graphml(in, mg);
read_graphml(in, mg, desired_idx);
}
template <typename Types>

View File

@@ -475,12 +475,12 @@ namespace boost {
* from every vertex to every other vertex, which is computed in the
* first stages of the algorithm. This value's type must be a model
* of BasicMatrix with value type equal to the value type of the
* weight map. The default is a a vector of vectors.
* weight map. The default is a vector of vectors.
*
* \param spring_strength (UTIL/OUT) will be used to store the
* strength of the spring between every pair of vertices. This
* value's type must be a model of BasicMatrix with value type equal
* to the value type of the weight map. The default is a a vector of
* to the value type of the weight map. The default is a vector of
* vectors.
*
* \param partial_derivatives (UTIL) will be used to store the

View File

@@ -21,7 +21,7 @@
#include <boost/graph/graph_traits.hpp>
// This file implements a utility for creating mappings from arbitrary
// identifers to the vertices of a graph.
// identifiers to the vertices of a graph.
namespace boost {
@@ -104,7 +104,7 @@ namespace graph_detail {
// Tag dispatch on random access containers (i.e., vectors). This function
// basically requires a) that Container is vector<Label> and that Label
// is an unsigned integral value. Note that this will resize the vector
// to accomodate indices.
// to accommodate indices.
template <typename Container, typename Graph, typename Label, typename Prop>
std::pair<typename graph_traits<Graph>::vertex_descriptor, bool>
insert_labeled_vertex(Container& c, Graph& g, Label const& l, Prop const& p,
@@ -112,7 +112,7 @@ namespace graph_detail {
{
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
// If the label is out of bounds, resize the vector to accomodate.
// If the label is out of bounds, resize the vector to accommodate.
// Resize by 2x the index so we don't cause quadratic insertions over
// time.
if(l >= c.size()) {
@@ -140,7 +140,7 @@ namespace graph_detail {
// Tag dispatch on unique associative containers (i.e. maps).
template <typename Container, typename Graph, typename Label, typename Prop>
std::pair<typename graph_traits<Graph>::vertex_descriptor, bool>
insert_labeled_vertex(Container& c, Graph& g, Label const& l, Prop const&,
insert_labeled_vertex(Container& c, Graph& g, Label const& l, Prop const& p,
unique_associative_container_tag)
{
// Here, we actually have to try the insertion first, and only add
@@ -150,6 +150,7 @@ namespace graph_detail {
std::pair<Iterator, bool> x = c.insert(std::make_pair(l, Vertex()));
if(x.second) {
x.first->second = add_vertex(g);
put(boost::vertex_all, g, x.first->second, p);
}
return std::make_pair(x.first->second, x.second);
}
@@ -246,7 +247,7 @@ struct labeled_graph_types {
* vertex labels and vertex descriptors.
*
* @todo This class is somewhat redundant for adjacency_list<*, vecS> if
* the intended label is an unsigned int (and perhpahs some other cases), but
* the intended label is an unsigned int (and perhaps some other cases), but
* it does avoid some weird ambiguities (i.e. adding a vertex with a label that
* does not match its target index).
*
@@ -310,7 +311,7 @@ public:
_map.insert(_map.end(), rng.first, rng.second);
}
// Construct a grpah over n vertices, each of which receives a label from
// Construct a graph over n vertices, each of which receives a label from
// the range [l, l + n). Note that the graph is not directly constructed
// over the n vertices, but added sequentially. This constructor is
// necessarily slower than the underlying counterpart.
@@ -544,8 +545,9 @@ inline bool label_vertex(typename LABELED_GRAPH::vertex_descriptor v,
{ return g.label_vertex(v, l); }
template <LABELED_GRAPH_PARAMS>
inline bool vertex_by_label(typename LABELED_GRAPH::label_type const l,
LABELED_GRAPH& g)
inline typename LABELED_GRAPH::vertex_descriptor
vertex_by_label(typename LABELED_GRAPH::label_type const l,
LABELED_GRAPH& g)
{ return g.vertex(l); }
//@}

View File

@@ -216,7 +216,7 @@ namespace boost
// Create tour using a preorder traversal of the mst
vector<Node> tour;
PreorderTraverser<Node, Tree> tvis(tour);
traverse_tree(0, t, tvis);
traverse_tree(indexmap[start], t, tvis);
pair<GVItr, GVItr> g_verts(vertices(g));
for(PreorderTraverser<Node, Tree>::const_iterator curr(tvis.begin());
@@ -228,7 +228,7 @@ namespace boost
}
// Connect back to the start of the tour
vis.visit_vertex(*g_verts.first, g);
vis.visit_vertex(start, g);
}
// Default tsp tour visitor that puts the tour in an OutputIterator

View File

@@ -11,14 +11,23 @@
#define BOOST_GRAPH_NAMED_GRAPH_HPP
#include <boost/config.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/functional/hash.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/properties.hpp>
#include <boost/multi_index/hashed_index.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index_container.hpp>
#include <boost/optional.hpp>
#include <boost/pending/property.hpp> // for boost::lookup_one_property
#include <boost/throw_exception.hpp>
#include <boost/tuple/tuple.hpp> // for boost::make_tuple
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility/enable_if.hpp>
#include <functional> // for std::equal_to
#include <stdexcept> // for std::runtime_error
#include <utility> // for std::pair
namespace boost { namespace graph {
@@ -352,8 +361,15 @@ find_vertex(typename BGL_NAMED_GRAPH::vertex_name_type const& name,
/// Retrieve the vertex associated with the given name, or add a new
/// vertex with that name if no such vertex is available.
/// Note: This is enabled only when the vertex property type is different
/// from the vertex name to avoid ambiguous overload problems with
/// the add_vertex() function that takes a vertex property.
template<BGL_NAMED_GRAPH_PARAMS>
Vertex
typename disable_if<is_same<
typename BGL_NAMED_GRAPH::vertex_name_type,
VertexProperty
>,
Vertex>::type
add_vertex(typename BGL_NAMED_GRAPH::vertex_name_type const& name,
BGL_NAMED_GRAPH& g)
{
@@ -401,6 +417,35 @@ add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
g.derived());
}
// Overloads to support EdgeMutablePropertyGraph graphs
template <BGL_NAMED_GRAPH_PARAMS>
std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
add_edge(typename BGL_NAMED_GRAPH::vertex_descriptor const& u,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
typename edge_property_type<Graph>::type const& p,
BGL_NAMED_GRAPH& g) {
return add_edge(u, add_vertex(v_name, g.derived()), p, g.derived());
}
template <BGL_NAMED_GRAPH_PARAMS>
std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_descriptor const& v,
typename edge_property_type<Graph>::type const& p,
BGL_NAMED_GRAPH& g) {
return add_edge(add_vertex(u_name, g.derived()), v, p, g.derived());
}
template <BGL_NAMED_GRAPH_PARAMS>
std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
typename edge_property_type<Graph>::type const& p,
BGL_NAMED_GRAPH& g) {
return add_edge(add_vertex(u_name, g.derived()),
add_vertex(v_name, g.derived()), p, g.derived());
}
#undef BGL_NAMED_GRAPH
#undef BGL_NAMED_GRAPH_PARAMS

View File

@@ -224,7 +224,7 @@ namespace boost {
{};
} // namespace detail
template <class Graph, class Property>
template <class Graph, class Property, class Enable = void>
struct property_map:
mpl::if_<
is_same<typename detail::property_kind_from_graph<Graph, Property>::type, edge_property_tag>,
@@ -248,8 +248,8 @@ namespace boost {
>::type type;
};
template <class Graph> class vertex_property: vertex_property_type<Graph> {};
template <class Graph> class edge_property: edge_property_type<Graph> {};
template <typename Graph> struct vertex_property: vertex_property_type<Graph> {};
template <typename Graph> struct edge_property: edge_property_type<Graph> {};
template <typename Graph>
class degree_property_map

View File

@@ -54,6 +54,39 @@ inline constant_property_map<Key, Value>
make_constant_property(const Value& value)
{ return constant_property_map<Key, Value>(value); }
/**
* Same as above, but pretends to be writable as well.
*/
template <typename Key, typename Value>
struct constant_writable_property_map {
typedef Key key_type;
typedef Value value_type;
typedef Value& reference;
typedef boost::read_write_property_map_tag category;
constant_writable_property_map()
: m_value()
{ }
constant_writable_property_map(const value_type &value)
: m_value(value)
{ }
constant_writable_property_map(const constant_writable_property_map& copy)
: m_value(copy.m_value)
{ }
friend Value get(const constant_writable_property_map& me, Key) {return me.m_value;}
friend void put(const constant_writable_property_map&, Key, Value) {}
value_type m_value;
};
template <typename Key, typename Value>
inline constant_writable_property_map<Key, Value>
make_constant_writable_property(const Value& value)
{ return constant_writable_property_map<Key, Value>(value); }
} /* namespace boost */
#endif

View File

@@ -433,7 +433,7 @@ namespace detail {
{
return m[k];
}
};
}
template <class E>
struct property_traits<detail::underlying_edge_desc_map_type<E> > {

View File

@@ -64,7 +64,7 @@ namespace boost
// basically modernized it to use real data structures (no more arrays and matrices).
// Oh... and there's explicit control structures - not just gotos.
//
// The problem is definitely NP-complete, an an unbounded implementation of this
// The problem is definitely NP-complete, an unbounded implementation of this
// will probably run for quite a while on a large graph. The conclusions
// of this paper also reference a Paton algorithm for undirected graphs as being
// much more efficient (apparently based on spanning trees). Although not implemented,
@@ -85,7 +85,7 @@ namespace boost
// }
/**
* The default cycle visitor providse an empty visit function for cycle
* The default cycle visitor provides an empty visit function for cycle
* visitors.
*/
struct cycle_visitor
@@ -168,7 +168,7 @@ namespace detail
// conditions for allowing a traversal along this edge are:
// 1. the index of v must be greater than that at which the
// the path is rooted (p.front()).
// path is rooted (p.front()).
// 2. the vertex v cannot already be in the path
// 3. the vertex v cannot be closed to the vertex u

View File

@@ -9,6 +9,10 @@
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/properties.hpp>
#include <boost/pending/property.hpp>
#include <boost/property_map/transform_value_property_map.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/if.hpp>
namespace boost
{
@@ -39,16 +43,16 @@ public:
typedef typename lookup_one_property<VertexProp, vertex_bundle_t>::type vertex_bundled;
typedef typename lookup_one_property<EdgeProp, edge_bundle_t>::type edge_bundled;
private:
public:
// Embed indices into the vertex type.
typedef property<vertex_index_t, unsigned, vertex_property_type> vertex_property;
typedef property<edge_index_t, unsigned, edge_property_type> edge_property;
typedef property<vertex_index_t, unsigned, vertex_property_type> internal_vertex_property;
typedef property<edge_index_t, unsigned, edge_property_type> internal_edge_property;
public:
typedef adjacency_list<listS,
listS,
undirectedS,
vertex_property,
edge_property,
internal_vertex_property,
internal_edge_property,
GraphProp,
listS> graph_type;
private:
@@ -151,7 +155,7 @@ public:
{ return make_index(boost::add_vertex(m_graph)); }
vertex_descriptor add_vertex(vertex_property_type const& p)
{ return make_index(boost::add_vertex(vertex_property(0u, p), m_graph)); }
{ return make_index(boost::add_vertex(internal_vertex_property(0u, p), m_graph)); }
void clear_vertex(vertex_descriptor v) {
std::pair<out_edge_iterator, out_edge_iterator>
@@ -188,7 +192,7 @@ public:
std::pair<edge_descriptor, bool>
add_edge(vertex_descriptor u, vertex_descriptor v,
edge_property_type const& p)
{ return make_index(boost::add_edge(u, v, edge_property(0u, p), m_graph)); }
{ return make_index(boost::add_edge(u, v, internal_edge_property(0u, p), m_graph)); }
void remove_edge(vertex_descriptor u, vertex_descriptor v) {
// find all edges, (u, v)
@@ -525,6 +529,30 @@ remove_in_edge_if(typename UNDIRECTED_GRAPH::vertex_descriptor v,
template <UNDIRECTED_GRAPH_PARAMS, typename Property>
struct property_map<UNDIRECTED_GRAPH, Property>: property_map<typename UNDIRECTED_GRAPH::graph_type, Property> {};
template <UNDIRECTED_GRAPH_PARAMS>
struct property_map<UNDIRECTED_GRAPH, vertex_all_t> {
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename UNDIRECTED_GRAPH::graph_type, vertex_all_t>::const_type>
const_type;
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename UNDIRECTED_GRAPH::graph_type, vertex_all_t>::type>
type;
};
template <UNDIRECTED_GRAPH_PARAMS>
struct property_map<UNDIRECTED_GRAPH, edge_all_t> {
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename UNDIRECTED_GRAPH::graph_type, edge_all_t>::const_type>
const_type;
typedef transform_value_property_map<
detail::remove_first_property,
typename property_map<typename UNDIRECTED_GRAPH::graph_type, edge_all_t>::type>
type;
};
// PropertyGraph concepts
template <UNDIRECTED_GRAPH_PARAMS, typename Property>
inline typename property_map<UNDIRECTED_GRAPH, Property>::type
@@ -536,6 +564,26 @@ inline typename property_map<UNDIRECTED_GRAPH, Property>::const_type
get(Property p, UNDIRECTED_GRAPH const& g)
{ return get(p, g.impl()); }
template <UNDIRECTED_GRAPH_PARAMS>
inline typename property_map<UNDIRECTED_GRAPH, vertex_all_t>::type
get(vertex_all_t, UNDIRECTED_GRAPH& g)
{ return typename property_map<UNDIRECTED_GRAPH, vertex_all_t>::type(detail::remove_first_property(), get(vertex_all, g.impl())); }
template <UNDIRECTED_GRAPH_PARAMS>
inline typename property_map<UNDIRECTED_GRAPH, vertex_all_t>::const_type
get(vertex_all_t, UNDIRECTED_GRAPH const& g)
{ return typename property_map<UNDIRECTED_GRAPH, vertex_all_t>::const_type(detail::remove_first_property(), get(vertex_all, g.impl())); }
template <UNDIRECTED_GRAPH_PARAMS>
inline typename property_map<UNDIRECTED_GRAPH, edge_all_t>::type
get(edge_all_t, UNDIRECTED_GRAPH& g)
{ return typename property_map<UNDIRECTED_GRAPH, edge_all_t>::type(detail::remove_first_property(), get(edge_all, g.impl())); }
template <UNDIRECTED_GRAPH_PARAMS>
inline typename property_map<UNDIRECTED_GRAPH, edge_all_t>::const_type
get(edge_all_t, UNDIRECTED_GRAPH const& g)
{ return typename property_map<UNDIRECTED_GRAPH, edge_all_t>::const_type(detail::remove_first_property(), get(edge_all, g.impl())); }
template <UNDIRECTED_GRAPH_PARAMS, typename Property, typename Key>
inline typename property_traits<
typename property_map<
@@ -545,10 +593,40 @@ inline typename property_traits<
get(Property p, UNDIRECTED_GRAPH const& g, Key const& k)
{ return get(p, g.impl(), k); }
template <UNDIRECTED_GRAPH_PARAMS, typename Key>
inline typename property_traits<
typename property_map<
typename UNDIRECTED_GRAPH::graph_type, vertex_all_t
>::const_type
>::value_type
get(vertex_all_t, UNDIRECTED_GRAPH const& g, Key const& k)
{ return get(vertex_all, g.impl(), k).m_base; }
template <UNDIRECTED_GRAPH_PARAMS, typename Key>
inline typename property_traits<
typename property_map<
typename UNDIRECTED_GRAPH::graph_type, edge_all_t
>::const_type
>::value_type
get(edge_all_t, UNDIRECTED_GRAPH const& g, Key const& k)
{ return get(edge_all, g.impl(), k).m_base; }
template <UNDIRECTED_GRAPH_PARAMS, typename Property, typename Key, typename Value>
inline void put(Property p, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(p, g.impl(), k, v); }
template <UNDIRECTED_GRAPH_PARAMS, typename Key, typename Value>
inline void put(vertex_all_t, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(vertex_all, g.impl(), k,
typename UNDIRECTED_GRAPH::internal_vertex_property(get(vertex_index, g.impl(), k), v));
}
template <UNDIRECTED_GRAPH_PARAMS, typename Key, typename Value>
inline void put(edge_all_t, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
{ put(edge_all, g.impl(), k,
typename UNDIRECTED_GRAPH::internal_vertex_property(get(edge_index, g.impl(), k), v));
}
template <UNDIRECTED_GRAPH_PARAMS, class Property>
inline typename graph_property<UNDIRECTED_GRAPH, Property>::type&
get_property(UNDIRECTED_GRAPH& g, Property p)

File diff suppressed because it is too large Load Diff

View File

@@ -244,6 +244,27 @@ namespace boost {
} // namespace detail
namespace detail {
// Stuff for directed_graph and undirected_graph to skip over their first
// vertex_index and edge_index properties when providing vertex_all and
// edge_all; make sure you know the exact structure of your properties if you
// use there.
struct remove_first_property {
template <typename F>
struct result {
typedef typename boost::function_traits<F>::arg1_type a1;
typedef typename boost::remove_reference<a1>::type non_ref;
typedef typename non_ref::next_type nx;
typedef typename boost::mpl::if_<boost::is_const<non_ref>, boost::add_const<nx>, nx>::type with_const;
typedef typename boost::add_reference<with_const>::type type;
};
template <typename Prop>
typename Prop::next_type& operator()(Prop& p) const {return p.m_base;}
template <typename Prop>
const typename Prop::next_type& operator()(const Prop& p) const {return p.m_base;}
};
}
} // namesapce boost
#endif /* BOOST_PROPERTY_HPP */