Boost logo

Boost Users :

Subject: Re: [Boost-users] BGL: Problem with dijkstra_shortest_paths
From: Alex Hagen-Zanker (ahh34_at_[hidden])
Date: 2011-06-30 09:56:10


Sorry, correction:
> 1. How to I define an edge id and set it when I build my graph?
You are already doing that with: graph[e].id = id;
You have to make sure that your template parameter E is the
edge_descriptor of G. So maybe use the following instead:

template <class G>
static void
graph_add_edge(G &graph, int id, int source, int target, float8 cost)
{
   typedef typename graph_traits<G>::edge_descriptor E;
   E e;
   bool inserted;
   tie(e, inserted) = add_edge(source, target, graph);
   graph[e].cost = cost;
   graph[e].id = id;
}

> 2. Given a vertex id and a predecessor id, How do I get the edge id?
>
template <class G>
static int
get_edge_id(G &graph, int source, int target)
{
   typedef typename graph_traits<G>::edge_descriptor E;;
   E e;
   bool found;
   tie(e, found) = edge(source, target, graph);
   return graph[e].id;
}

-- 
Alex Hagen-Zanker
University of Cambridge, Department of Architecture,  1-5 Scroope Terrace, Cambridge, CB2 1PX, United Kingdom
Tel: +44(0) 1223 330573

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