Boost logo

Boost :

Subject: [boost] [BGL] on using visitor in dijkstra_shortest_path
From: Sandeep Gupta (gupta.sandeep_at_[hidden])
Date: 2009-07-01 19:22:59


Hi,
 The example code for extending dijkstra via gives compilation errors.
Attached below is the snippet code and the error messages using gcc-4.3.3
and boost_138_0.

typedef boost::adjacency_list<vecS, vecS, bidirectionalS > graphImpl_t;

//----taken for doc---
template <class PredecessorMap>
class record_predecessors : public dijkstra_visitor<>
{
  public:
  record_predecessors(PredecessorMap p)
      : m_predecessor(p) { }

    template <class Edge, class Graph>
    void edge_relaxed(Edge e, Graph& g) {
      // set the parent of the target(e) to source(e)
      put(m_predecessor, target(e, g), source(e, g));
    }
  protected:
    PredecessorMap m_predecessor;
  };

template <class PredecessorMap>
record_predecessors<PredecessorMap> //error: expected constructor,
destructor, or type conversion before ‘<’ token
  make_predecessor_recorder(PredecessorMap p) {
    return record_predecessors<PredecessorMap>(p);
  }
///---end doc--------------
.....
...
 vector<vertex_t> p(num_vertices(gg));
  dijkstra_shortest_paths(gg, src,
predecessor_map(preds).weight_map(weights).distance_map(dists).visitor(make_predecessor_recorder(&p[0])));

Thanks in advance.
-sandeep


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk