From 5bb73cd8993ef97b201d95f644790d77f2d80d06 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 29 May 2021 20:34:01 +0300 Subject: [PATCH 1/3] Add CMakeLists.txt --- CMakeLists.txt | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..2300cb340 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,81 @@ +# Generated by `boostdep --cmake graph` +# Copyright 2020 Peter Dimov +# Distributed under the Boost Software License, Version 1.0. +# https://www.boost.org/LICENSE_1_0.txt + +cmake_minimum_required(VERSION 3.5...3.16) + +project(boost_graph VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) + +add_library(boost_graph + src/graphml.cpp + src/read_graphviz_new.cpp +) + +add_library(Boost::graph ALIAS boost_graph) + +target_include_directories(boost_graph PUBLIC include) + +target_link_libraries(boost_graph + PUBLIC + Boost::algorithm + Boost::any + Boost::array + Boost::assert + Boost::bimap + Boost::bind + Boost::concept_check + Boost::config + Boost::container_hash + Boost::conversion + Boost::core + Boost::detail + Boost::foreach + Boost::function + Boost::integer + Boost::iterator + Boost::lexical_cast + Boost::math + Boost::move + Boost::mpl + Boost::multi_index + Boost::optional + Boost::parameter + Boost::preprocessor + Boost::property_map + Boost::property_tree + Boost::random + Boost::range + Boost::serialization + Boost::smart_ptr + Boost::spirit + Boost::static_assert + Boost::throw_exception + Boost::tti + Boost::tuple + Boost::type_traits + Boost::typeof + Boost::unordered + Boost::utility + Boost::xpressive + PRIVATE + Boost::regex +) + +target_compile_definitions(boost_graph + PUBLIC BOOST_GRAPH_NO_LIB + PRIVATE BOOST_GRAPH_SOURCE +) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(boost_graph PUBLIC BOOST_GRAPH_DYN_LINK) +else() + target_compile_definitions(boost_graph PUBLIC BOOST_GRAPH_STATIC_LINK) +endif() + +if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") + + add_subdirectory(test) + +endif() + From 2bc8d0490e3b2b8fdeb37519084a316c4834d572 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 9 Jun 2021 18:45:39 +0300 Subject: [PATCH 2/3] Do not define BOOST_GRAPH_SOURCE in CMakeLists.txt --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2300cb340..0e294eb5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ -# Generated by `boostdep --cmake graph` -# Copyright 2020 Peter Dimov +# Copyright 2020, 2021 Peter Dimov # Distributed under the Boost Software License, Version 1.0. # https://www.boost.org/LICENSE_1_0.txt @@ -64,7 +63,8 @@ target_link_libraries(boost_graph target_compile_definitions(boost_graph PUBLIC BOOST_GRAPH_NO_LIB - PRIVATE BOOST_GRAPH_SOURCE + # Source files already define BOOST_GRAPH_SOURCE + # PRIVATE BOOST_GRAPH_SOURCE ) if(BUILD_SHARED_LIBS) @@ -78,4 +78,3 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") add_subdirectory(test) endif() - From 260dc018d08d1d10c95a950d1467f32909d1fbae Mon Sep 17 00:00:00 2001 From: etienneINSA Date: Fri, 3 Jun 2022 11:42:59 +0200 Subject: [PATCH 3/3] add test for stoer_wagner --- test/stoer_wagner_test.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/stoer_wagner_test.cpp b/test/stoer_wagner_test.cpp index 2b9808616..21f667a18 100644 --- a/test/stoer_wagner_test.cpp +++ b/test/stoer_wagner_test.cpp @@ -184,6 +184,32 @@ void test4() BOOST_TEST_EQ(parity2, get(parities, 7)); } +// Non regression test for github.com/boostorg/graph/isssues/286 +void test5() +{ + edge_t edges[] = { { 0, 1 }, { 0, 2 }, { 0, 3 }, { 1, 2 }, { 1, 3 }, + { 2, 3 }, { 4, 5 }, { 4, 6 }, { 4, 7 }, { 5, 6 }, { 5, 7 }, { 6, 7 }, + {0, 4} }; + weight_type ws[] = { 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 6 }; + undirected_graph g(edges, edges + 13, ws, 8, 13); + + weight_map_type weights = get(boost::edge_weight, g); + std::map< int, bool > parity; + boost::associative_property_map< std::map< int, bool > > parities(parity); + int w + = boost::stoer_wagner_min_cut(g, weights, boost::parity_map(parities)); + BOOST_TEST_EQ(w, 7); + const bool parity0 = get(parities, 0); + BOOST_TEST_EQ(parity0, get(parities, 1)); + BOOST_TEST_EQ(parity0, get(parities, 2)); + BOOST_TEST_EQ(parity0, get(parities, 3)); + const bool parity4 = get(parities, 4); + BOOST_TEST_NE(parity0, parity4); + BOOST_TEST_EQ(parity4, get(parities, 5)); + BOOST_TEST_EQ(parity4, get(parities, 6)); + BOOST_TEST_EQ(parity4, get(parities, 7)); +} + // The input for the `test_prgen` family of tests comes from a program, named // `prgen`, that comes with a package of min-cut solvers by Chandra Chekuri, // Andrew Goldberg, David Karger, Matthew Levine, and Cliff Stein. `prgen` was @@ -292,6 +318,7 @@ int main(int argc, char* argv[]) test2(); test3(); test4(); + test5(); test_prgen_20_70_2(); test_prgen_50_70_2(); }