Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] add_edge also adds a vertex
From: Eric Wolf (eric_at_[hidden])
Date: 2010-02-08 12:35:42


Hi Olivier,

Olivier Tournaire <olitour_at_[hidden]> writes:

> Here is the code:
>
> #include <iostream>
> #include <vector>
> using namespace std;
>
> #include <boost/graph/kolmogorov_max_flow.hpp>
> #include <boost/graph/adjacency_list.hpp>
> using namespace boost;
>
> typedef adjacency_list_traits < vecS, vecS, directedS > Traits;
> typedef adjacency_list < vecS, vecS, directedS,
> property < vertex_index_t, long,
> property < vertex_color_t, boost::default_color_type,
> property < vertex_distance_t, long,
> property < vertex_potential_t, long, // stores the unary energy associated to
> each vertex
> property < vertex_predecessor_t, Traits::edge_descriptor > > > > >,
> property < edge_capacity_t, long, // stores the binary energy associated to
> each edge
> property < edge_residual_capacity_t, long,
> property < edge_reverse_t, Traits::edge_descriptor > > > > Graph;
>
>
> int main(int argc, char** argv)
> {
>     Graph g;
>
>     property_map<Graph, edge_capacity_t>::type capacity = get(edge_capacity,
> g);
>     property_map<Graph, edge_reverse_t>::type rev = get(edge_reverse, g);

add_vertex(g);
add_vertex(g);
add_vertex(g);
or so ...

>     graph_traits<Graph>::vertex_iterator v_first, v_second, v_third;
>     v_first = vertices(g).first;
>     v_second = v_first;
>     ++v_second;
>     v_third = v_second;
>     ++v_third;

Did you forget to add a few vertices before calling vertices(g) ?

Eric


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