Boost logo

Boost Users :

Subject: Re: [Boost-users] [Graph] undefined trait functions
From: Miklós Tóth (spiralfuzet_at_[hidden])
Date: 2013-05-07 05:09:32


Hi!

I've tried to include the <boost/graph/adjacency_list.hppÿ> but it hasn't
changed anything.
Let's see the code:
1. I have the graph adaptor struct as in my first mail
2. Trait functions in the header (where i tried to include
adjacency_list.hpp). I still think it's not neccessary to copy the vertex,
and edge iterator implementations (of course i'll do it if you say so):

namspace boost ÿ{

    struct legacy_graph_traversal_category ÿ{...};

namespace detail ÿ{

    struct traits_base {...};
} // namespace detail

// general adapted graph traits
template <>
struct graph_traits<legacy_graph_adaptor> : public detail::traits_base {
    struct out_edge_iterator : public
detail::traits_base::edge_iter_base<out_edge_iterator>
    {
        typedef detail::traits_base::edge_iter_base<out_edge_iterator> Base;

        out_edge_iterator(int legacy_vertex = 0, int* base_to = 0,
            const legacy_graph* g = 0) : Base(legacy_vertex, base_to, g) { }
    private:
        void increment() {
            advance();
        }
        friend class iterator_core_access;
    };
};

graph_traits<legacy_graph_adaptor>::vertex_descriptor
    source(graph_traits<legacy_graph_adaptor>::edge_descriptor e,
                const legacy_graph_adaptor& g);

graph_traits<legacy_graph_adaptor>::vertex_descriptor
    target(graph_traits<legacy_graph_adaptor>::edge_descriptor e,
                const legacy_graph_adaptor& g);

graph_traits<legacy_graph_adaptor>::vertices_size_type
    num_vertices(const legacy_graph_adaptor& g);

std::pair<boost::graph_traits<legacy_graph_adaptor>::vertex_iterator,
        boost::graph_traits<legacy_graph_adaptor>::vertex_iterator>
    vertices(const legacy_graph_adaptor& g);

graph_traits<legacy_graph_adaptor>::degree_size_type
    out_degree(graph_traits<legacy_graph_adaptor>::vertex_descriptor v,
                const legacy_graph_adaptor& g);

std::pair<graph_traits<legacy_graph_adaptor>::out_edge_iterator,
        graph_traits<legacy_graph_adaptor>::out_edge_iterator>
    out_edges(graph_traits<legacy_graph_adaptor>::vertex_descriptor v,
                const legacy_graph_adaptor& g);

} // namespace boost

All this functions are declareted in the corresponding cpp file.

Best regards:
Miklos

2013/5/3 Jeremiah Willcock <jewillco_at_[hidden]>

> On Fri, 3 May 2013, Miklós Tóth wrote:
>
> Hi!
>>
>> I've a problem, with Boost Graph Library and gcc 4.7.
>> I have a legacy graph representation that i like to wrap with a graph
>> adaptor to access boost graph algorythms.
>>
>> 1: I've created a graph adaptor, that contains my legacy graph. This is a
>> simple struct:
>>
>> struct legacy_graph_adaptor {
>> legacy_graph_adaptor(const legacy_graph& g)
>> : graph(const_cast<legacy_graph&**>(g)) { }
>> legacy_graph& graph;
>> };
>>
>> 2: Next step was a vertex_iterator and an edge_itreator, where I
>> redefined the equal, dereference, increment, etc members. (If it's not
>> necessary i'm not
>> going to copy the code here.)
>>
>> 3: Created traits for adapted graph. I've redefined source, target,
>> out_edge, etc.
>> template <>
>>
>> struct graph_traits<legacy_graph_**adaptor> : public detail::traits_base
>> {
>> struct out_edge_iterator :
>> public detail::traits_base::edge_**iter_base<out_edge_iterator>
>> {
>> typedef detail::traits_base::edge_**iter_base<out_edge_iterator>
>> Base;
>>
>> out_edge_iterator(int legacy_vertex = 0, int* base_to = 0,
>> const legacy_graph* g = 0) : Base(legacy_vertex, base_to, g)
>> { }
>> private:
>> void increment() {
>> advance();
>> }
>> friend class iterator_core_access;
>> };
>> };
>>
>> Originally it was created as a part of a msvc project. Now I try to port
>> it to gcc, and i got the next message (for example):
>>
>> <path_to>\boost\boost_1_53_0\**boost\graph\graph_concepts.**hpp:94:
>> error: 'out_edges' was not declared in this scope, and no declarations were
>> found by
>> argument-dependent lookup at the point of instantiation [-fpermissive]
>>
>> When I change to gcc 4.6 it compiles well.
>> So my question is: Is this a known bug or I missing something?
>> Thanks for the help.
>>
>
> I can't tell from the code snippet. Could you please try including
> <boost/graph/adjacency_list.**hpp> before any other Boost.Graph files and
> see if that changes anything? If so, that is probably a bug in
> Boost.Graph; if not, we will need to look more at how your declarations of
> functions are ordered relative to their uses.
>
> -- Jeremiah Willcock
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net