Ticket #7766: named_graph.patch

File named_graph.patch, 2.7 KB (added by Louis Dionne <louis.dionne92@…>, 10 years ago)

Add 3 overloads of add_edge and missing includes.

  • boost/graph/named_graph.hpp

    diff --git a/boost/graph/named_graph.hpp b/boost/graph/named_graph.hpp
    index 1150e43..4c687a0 100644
    a b  
    1111#define BOOST_GRAPH_NAMED_GRAPH_HPP
    1212
    1313#include <boost/config.hpp>
    14 #include <boost/type_traits/is_same.hpp>
    15 #include <boost/type_traits/remove_cv.hpp>
    16 #include <boost/type_traits/remove_reference.hpp>
    17 #include <boost/multi_index_container.hpp>
     14#include <boost/functional/hash.hpp>
     15#include <boost/graph/graph_traits.hpp>
     16#include <boost/graph/properties.hpp>
    1817#include <boost/multi_index/hashed_index.hpp>
    1918#include <boost/multi_index/member.hpp>
     19#include <boost/multi_index_container.hpp>
    2020#include <boost/optional.hpp>
     21#include <boost/pending/property.hpp> // for boost::lookup_one_property
    2122#include <boost/throw_exception.hpp>
     23#include <boost/tuple/tuple.hpp> // for boost::make_tuple
     24#include <boost/type_traits/is_same.hpp>
     25#include <boost/type_traits/remove_cv.hpp>
     26#include <boost/type_traits/remove_reference.hpp>
    2227#include <boost/utility/enable_if.hpp>
     28#include <functional> // for std::equal_to
    2329#include <stdexcept> // for std::runtime_error
     30#include <utility> // for std::pair
    2431
    2532namespace boost { namespace graph {
    2633
    add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,  
    410417                  g.derived());
    411418}
    412419
     420// Overloads to support EdgeMutablePropertyGraph graphs
     421template <BGL_NAMED_GRAPH_PARAMS>
     422std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
     423add_edge(typename BGL_NAMED_GRAPH::vertex_descriptor const& u,
     424         typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
     425         typename edge_property_type<Graph>::type const& p,
     426         BGL_NAMED_GRAPH& g) {
     427    return add_edge(u, add_vertex(v_name, g.derived()), p, g.derived());
     428}
     429
     430template <BGL_NAMED_GRAPH_PARAMS>
     431std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
     432add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
     433         typename BGL_NAMED_GRAPH::vertex_descriptor const& v,
     434         typename edge_property_type<Graph>::type const& p,
     435         BGL_NAMED_GRAPH& g) {
     436    return add_edge(add_vertex(u_name, g.derived()), v, p, g.derived());
     437}
     438
     439template <BGL_NAMED_GRAPH_PARAMS>
     440std::pair<typename graph_traits<Graph>::edge_descriptor, bool>
     441add_edge(typename BGL_NAMED_GRAPH::vertex_name_type const& u_name,
     442         typename BGL_NAMED_GRAPH::vertex_name_type const& v_name,
     443         typename edge_property_type<Graph>::type const& p,
     444         BGL_NAMED_GRAPH& g) {
     445    return add_edge(add_vertex(u_name, g.derived()),
     446                    add_vertex(v_name, g.derived()), p, g.derived());
     447}
     448
    413449#undef BGL_NAMED_GRAPH
    414450#undef BGL_NAMED_GRAPH_PARAMS
    415451