Boost logo

Boost Users :

Subject: [Boost-users] [graph] adjacency_list constructor fails, wrong usage?
From: Christoph (c_p_at_[hidden])
Date: 2011-10-24 04:41:05


Hi,

I originally wanted to construct an undirected graph from a directed
graph and vice versa. For this purpose i tried to use

template <class EdgeIterator>
adjacency_list(EdgeIterator first, EdgeIterator last,
               vertices_size_type n,
               edges_size_type m = 0,
               const GraphProperty& p = GraphProperty())

as shown in

http://www.boost.org/doc/libs/1_47_0/libs/graph/doc/adjacency_list.html

but i do not even manage to construct a graph from the same type with
this constructor. What am i missing? Please have a look at the example
below. If you uncomment the last two lines, the code will not compile.

// begin code
#include <iostream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>

int main(int argc, char** argv) {
typedef boost::adjacency_list < boost::listS,
                                boost::vecS,
                                boost::directedS>
Dgraph;
typedef boost::adjacency_list < boost::listS,
                                boost::vecS,
                                boost::undirectedS>
Graph;

Dgraph g(5);
add_edge (0,1,g);add_edge (2,3,g);add_edge (4,5,g);
print_graph (g, boost::get(boost::vertex_index, g));
        
boost::graph_traits<Dgraph>::edge_iterator i1 = (edges(g)).first;
boost::graph_traits<Dgraph>::edge_iterator i2 = (edges(g)).second;
// Dgraph g2 = Dgraph (i1, i2, num_vertices (g), num_edges (g));
// print_graph (g2, boost::get(boost::vertex_index, g2));
return 0;
}
// end code

best regards
Christoph


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