Boost logo

Boost Users :

Subject: [Boost-users] [BGL] passing a graph from one function to another
From: r89 (r8921025_at_[hidden])
Date: 2008-11-19 10:54:27

Hi all,

I have a graph defined as follows (the same as in the Dijkstra shortest path
example code):

typedef adjacency_list < listS, vecS, directedS, no_property, property <
edge_weight_t, float > > graph_t;

The following works fine:
graph_t myGraph(array, edge_array + num_arcs, weights, num_nodes);

However, now I want to do the above line inside a function (say, fun_A), and
I want another function (say, fun_B) to have access to "myGraph".

How should I do that? I wish I could do something like this:

graph_t myGraph;

fun_A(graph_t &myGraph) {
myGraph(array, edge_array + num_arcs, weights, num_nodes);

fun_B(graph_t &myGraph) {
// using myGraph to run some graph algorithm...

but it doesn't work. Any suggestions?

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at