Boost logo

Boost Users :

From: richardshaw11 (richard.shaw_at_[hidden])
Date: 2002-08-23 01:38:33


In my last mail I didn't say how it failed.

It gets a bad address for the property - so for the weight it
displays a large meaningless number, for a string property it prints
pages of garbage - I was surprised how few zeros were in memory !

I had a look at the implementation of edge() and I see that it
returns the following -
edge_descriptor(u, v, &(*i).get_property()

my code just returns the contents of the out_edge_iterator

I changed my function to return -
        return std::make_pair(true,
                graph_traits<Graph>::edge_descriptor(u, v,
(*ei).get_property()));

but it made no difference.

I tried using edge() and it works OK.

Strange.

--- In Boost-Users_at_y..., Tarjei Knapstad <tarjeik_at_c...> wrote:
> On Thu, 2002-08-22 at 10:19, Shaw, Richard A wrote:
> > Can anybody tell my why the find_edge function in the code below
fails to
> > get a property if I return the first edge in the list.
> >
> > This is what happens -
> >
> > Find_edge looks for edge A - B
> > It winds it and prints out the edge descriptor, and the weight of
the edge
> > It the returns the edge
> > The main code prints out the edge descriptor and the fails when
trying to
> > print the weight.
> >
> > BTW - Is there a ready made function to find an edge based on the
vertices ?
> >
> > #include <boost/config.hpp>
> > #include <iostream>
> > #include <fstream>
> >
> > #include <boost/graph/graph_traits.hpp>
> > #include <boost/graph/adjacency_list.hpp>
> > #include <boost/graph/dijkstra_shortest_paths.hpp>
> >
> > using namespace boost;
> >
> > // Find edge
> > template <class Graph>
> > std::pair<bool, graph_traits<Graph>::edge_descriptor>
> > find_edge(graph_traits<Graph>::vertex_descriptor u,
> > graph_traits<Graph>::vertex_descriptor v,
> > Graph g)
>
> It's a lot more efficient to pass a const reference to
> the graph you're searching in.
>
> As Jeremy though, I cannot reproduce your problem using gcc 3.1 and
> either of boost 1.2.8 or the latest CVS source tree.
>
> Regards,
> Tarjei


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