Boost logo

Boost Users :

Subject: Re: [Boost-users] Missing something about Boost.Graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2015-10-28 08:43:28


>________________________________
> From: Dominique Devienne <ddevienne_at_[hidden]>
>To: boost-users <boost-users_at_[hidden]>
>Sent: Wednesday, October 28, 2015 2:52 AM
>Subject: [Boost-users] Missing something about Boost.Graph
>
>
>
>We have a graph of relational tables, with the foreign keys being the edges of the graph.
>We're using boost::topological_sort() to sort the graph, and have struggled in the past with Boost.Graph.
>
>
>Recently we had cycles appearing in our graph, so I'm revisiting this code, and I think I must be missing something fundamental about Boost.Graph, because I get what I consider incoherent results. Here are the relevant code snippets.
>
> typedef std::pair<std::size_t, std::size_t> IndexPair;
> std::vector<IndexPair> edges;
>
>
>// fill edges with pairs of integers, in range [0, 111] (at the moment)
>
>
> using namespace boost;
> typedef property<vertex_color_t, default_color_type> GraphProperty;
> typedef adjacency_list<vecS, vecS, directedS, GraphProperty> Graph;
> typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
>
>

> Graph G(edges.begin(), edges.end(), edges.size());

The third parameter to the constructor is the number of vertices, not the number of edges. If you want to give the edge count explicitly, that is placed as the fourth parameter, after the edge count.

-- Jeremiah Willcock


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