Skip to content

Commit

Permalink
Fixed tests that failed due to new 'connect_neighbour' argument
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jul 26, 2019
1 parent 2f8c167 commit 2203cea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@
#include <vector>
template <typename graph>
std::vector<graph>
create_all_direct_neighbour_bundled_edges_and_vertices_subgraphs(const graph g)
create_all_direct_neighbour_bundled_edges_and_vertices_subgraphs(
const graph g,
const bool connect_neighours = false
)
{
using vd = typename graph::vertex_descriptor;

std::vector<graph> v;
v.resize(boost::num_vertices(g));
const auto vip = vertices(g);
std::transform(vip.first, vip.second, std::begin(v), [&g](const vd& d) {
return create_direct_neighbour_bundled_edges_and_vertices_subgraph(d, g);
std::transform(
vip.first,
vip.second,
std::begin(v),
[&g, connect_neighours](const vd& d) {
return create_direct_neighbour_bundled_edges_and_vertices_subgraph(
d, g, connect_neighours
);
});
return v;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ BOOST_AUTO_TEST_CASE(
{
const auto v
= create_all_direct_neighbour_bundled_edges_and_vertices_subgraphs(
create_bundled_edges_and_vertices_k3_graph());
create_bundled_edges_and_vertices_k3_graph(),
true // connect the neighbours
);
BOOST_CHECK(v.size() == 3);
for (const auto g : v) {
BOOST_CHECK(boost::num_vertices(g) == 3);
BOOST_CHECK(boost::num_edges(g) == 3);
for (const auto& g : v) {
BOOST_CHECK_EQUAL(3, boost::num_vertices(g));
BOOST_CHECK_EQUAL(3, boost::num_edges(g));
const my_bundled_vertex va("Red", "Not green", 1.0, 2.0);
const my_bundled_vertex vb("Light red", "Not dark", 3.0, 4.0);
const my_bundled_vertex vc("Orange", "Orangy", 5.0, 6.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ BOOST_AUTO_TEST_CASE(
const auto j = vip.second;
for (auto i = vip.first; i != j; ++i) {
const auto h
= create_direct_neighbour_bundled_edges_and_vertices_subgraph(*i, g);
BOOST_CHECK(boost::num_vertices(h) == 3);
BOOST_CHECK(boost::num_edges(h) == 3);
= create_direct_neighbour_bundled_edges_and_vertices_subgraph(
*i, g,
true // connect the neighbours
);
BOOST_CHECK_EQUAL(3, boost::num_vertices(h));
BOOST_CHECK_EQUAL(3, boost::num_edges(h));
const auto v = get_my_bundled_vertexes(h);
std::set<my_bundled_vertex> vertexes(std::begin(v), std::end(v));
const auto e = get_my_bundled_edges(h);
Expand All @@ -54,12 +57,12 @@ BOOST_AUTO_TEST_CASE(
const my_bundled_edge ea("Oxygen", "Air", 1.0, 2.0);
const my_bundled_edge eb("Helium", "From tube", 3.0, 4.0);
const my_bundled_edge ec("Stable temperature", "Here", 5.0, 6.0);
BOOST_CHECK(vertexes.count(va) == 1);
BOOST_CHECK(vertexes.count(vb) == 1);
BOOST_CHECK(vertexes.count(vc) == 1);
BOOST_CHECK(edges.count(ea) == 1);
BOOST_CHECK(edges.count(eb) == 1);
BOOST_CHECK(edges.count(ec) == 1);
BOOST_CHECK_EQUAL(1, vertexes.count(va));
BOOST_CHECK_EQUAL(1, vertexes.count(vb));
BOOST_CHECK_EQUAL(1, vertexes.count(vc));
BOOST_CHECK_EQUAL(1, edges.count(ea));
BOOST_CHECK_EQUAL(1, edges.count(eb));
BOOST_CHECK_EQUAL(1, edges.count(ec));
}
}
// Path graph
Expand Down
Binary file modified boost_graph_cookbook_1/title_graph.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2203cea

Please sign in to comment.