Boost logo

Boost Users :

From: Irek Szczesniak (ijs_at_[hidden])
Date: 2006-04-23 03:01:25


Vertexes in my graph have the distance and predecessor properties.
These properties at each vertex are vectors: they store distances and
predecessor of shortest paths to every other node in the graph.

Below is my program. I run the program and as input I give the file
also listed below, and get this run-time error:

*** glibc detected *** free(): invalid next size (fast): 0x085dd110

I would appreciate your advice on what I'm doing wrong.

Best,
Irek

**********************************************************************

#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/iteration_macros.hpp>
#include <boost/graph/graphviz.hpp>

using namespace std;
using namespace boost;

typedef
adjacency_list_traits<vecS, vecS, undirectedS>::vertex_descriptor
Vertex;

typedef
boost::adjacency_list <vecS, vecS, undirectedS,
        property<vertex_name_t, string,
        property<vertex_distance_t, vector<int>,
        property<vertex_predecessor_t, vector<Vertex> > > >,
        property<edge_weight_t, int,
        property<edge_weight2_t, int> > >
Graph;

int
main ()
{
   Graph g;
   dynamic_properties dp;

   dp.property("node_id", get(vertex_name, g));
   dp.property("distance", get(edge_weight, g));
   dp.property("lambdas", get(edge_weight2, g));

   read_graphviz(cin, g, dp);

   BGL_FORALL_VERTICES(v, g, Graph)
     {
       get(vertex_distance, g, v).resize(num_vertices(g));
       get(vertex_predecessor, g, v).resize(num_vertices(g));

       dijkstra_shortest_paths
        (g, v, predecessor_map(&get(vertex_predecessor, g, v)[0]).
         distance_map(&get(vertex_distance, g, v)[0]));
     }
}

**********************************************************************

Graph {
   a;
   b;
   c;
   d;
   e;
   f;

   a -- b [distance = "100", lambdas = "10"]
   b -- c [distance = "200", lambdas = "10"]
   c -- d [distance = "80", lambdas = "10"]
   b -- e [distance = "40", lambdas = "10"]
   c -- f [distance = "100", lambdas = "10"]
   a -- e [distance = "210", lambdas = "10"]
   e -- f [distance = "340", lambdas = "10"]
   f -- d [distance = "50", lambdas = "10"]
}


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