diff --git a/.clang-format b/.clang-format index e73f6d56b..81a8918f3 100644 --- a/.clang-format +++ b/.clang-format @@ -5,6 +5,7 @@ AlignEscapedNewlinesLeft: true AlwaysBreakAfterDefinitionReturnType: None BreakBeforeBraces: Allman BreakConstructorInitializersBeforeComma: false +BreakTemplateDeclarations: Yes ColumnLimit: 80 ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 0 diff --git a/.drone.star b/.drone.star index f96e29474..174783596 100644 --- a/.drone.star +++ b/.drone.star @@ -14,12 +14,6 @@ windowsglobalimage="cppalliance/dronevs2019" def main(ctx): return [ - linux_cxx("g++-5 14", "g++-5", packages="g++-5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '14', }, globalenv=globalenv), - linux_cxx("g++-5 1z", "g++-5", packages="g++-5", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-5', 'CXXSTD': '1z', }, globalenv=globalenv), - - linux_cxx("g++-6 14", "g++-6", packages="g++-6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '14', }, globalenv=globalenv), - linux_cxx("g++-6 1z", "g++-6", packages="g++-6", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-6', 'CXXSTD': '1z', }, globalenv=globalenv), - linux_cxx("g++-7 14", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("g++-7 17", "g++-7", packages="g++-7", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-7', 'CXXSTD': '17', }, globalenv=globalenv), @@ -33,23 +27,15 @@ def main(ctx): linux_cxx("g++-10 14", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("g++-10 17", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '17', }, globalenv=globalenv), linux_cxx("g++-10 20", "g++-10", packages="g++-10", image="cppalliance/droneubuntu2004:1", buildtype="boost", environment={'TOOLSET': 'gcc', 'COMPILER': 'g++-10', 'CXXSTD': '20', }, globalenv=globalenv), - - linux_cxx("clang++-4.0 14", "clang++-4.0", packages="clang-4.0", llvm_os="xenial", llvm_ver="4.0", buildtype="boost", image=linuxglobalimage, environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-4.0', 'CXXSTD': '14', }, globalenv=globalenv), - - linux_cxx("clang++-5.0 14", "clang++-5.0", packages="clang-5.0", llvm_os="xenial", llvm_ver="5.0", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-5.0', 'CXXSTD': '14', }, globalenv=globalenv), - - linux_cxx("clang++-6.0 14", "clang++-6.0", packages="clang-6.0", llvm_os="xenial", llvm_ver="6.0", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-6.0', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("clang++-7 14", "clang++-7", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("clang++-7 17", "clang++-7", packages="clang-7", llvm_os="xenial", llvm_ver="7", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-7', 'CXXSTD': '17', }, globalenv=globalenv), linux_cxx("clang++-8 14", "clang++-8", packages="clang-8", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("clang++-8 17", "clang++-8", packages="clang-8", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '17', }, globalenv=globalenv), - linux_cxx("clang++-8 2a", "clang++-8", packages="clang-8", llvm_os="xenial", llvm_ver="8", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-8', 'CXXSTD': '2a', }, globalenv=globalenv), linux_cxx("clang++-9 14", "clang++-9", packages="clang-9", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("clang++-9 17", "clang++-9", packages="clang-9", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '17', }, globalenv=globalenv), - linux_cxx("clang++-9 2a", "clang++-9", packages="clang-9", llvm_os="xenial", llvm_ver="9", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-9', 'CXXSTD': '2a', }, globalenv=globalenv), linux_cxx("clang++-10 14", "clang++-10", packages="clang-10", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '14', }, globalenv=globalenv), linux_cxx("clang++-10 17", "clang++-10", packages="clang-10", llvm_os="xenial", llvm_ver="10", buildtype="boost", image="cppalliance/droneubuntu1804:1", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++-10', 'CXXSTD': '17', }, globalenv=globalenv), @@ -57,7 +43,6 @@ def main(ctx): osx_cxx("XCode-11.7 14", "clang++", packages="", buildtype="boost", xcode_version="11.7", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '14', }, globalenv=globalenv), osx_cxx("XCode-11.7 17", "clang++", packages="", buildtype="boost", xcode_version="11.7", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '17', }, globalenv=globalenv), - osx_cxx("XCode-11.7 2a", "clang++", packages="", buildtype="boost", xcode_version="11.7", environment={'TOOLSET': 'clang', 'COMPILER': 'clang++', 'CXXSTD': '2a', }, globalenv=globalenv), ] # from https://github.com/boostorg/boost-ci diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fef3d3562..181121e61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,16 +7,15 @@ name: CI on: [ push, pull_request ] jobs: - ubuntu-focal: - runs-on: ubuntu-20.04 + ubuntu: + runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: - # Removed g++-10 because of an ICE; meant to be fixed in 10.2? - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94938 - compiler: [ g++-9, clang++-10 ] + compiler: [ gcc-14, clang-19 ] + cxxstd: [ 14, 17, 20, 23 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@master with: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 @@ -24,12 +23,12 @@ jobs: commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[windows];[Windows];[WINDOWS];[apple];[Apple];[APPLE]' commit-filter-separator: ';' fail-fast: true - - name: Set TOOLSET - run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV - - name: Add repository - run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test" + - name: Set ENV + run: | + echo ${{ matrix.compiler }} | awk '/^gcc/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV + echo ${{ matrix.compiler }} | awk '/^gcc/ { gsub(/gcc/,"CXX=g++"); print; } /^clang/ { gsub(/clang/,"CXX=clang++"); print; }' >> $GITHUB_ENV - name: Install packages - run: sudo apt install g++-9 clang-10 + run: sudo apt install ${{ matrix.compiler }} - name: Checkout main boost run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - name: Update tools/boostdep @@ -48,13 +47,13 @@ jobs: run: ./b2 headers working-directory: ../boost-root - name: Generate user config - run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} ;" > ~/user-config.jam' + run: 'echo "using $TOOLSET : : $CXX ;" > ~/user-config.jam' working-directory: ../boost-root - name: Config info - run: ../../../b2 print_config_info toolset=$TOOLSET cxxstd=14,17,2a + run: ../../../b2 print_config_info toolset=$TOOLSET cxxstd=${{ matrix.cxxstd }} working-directory: ../boost-root/libs/config/test - name: Test - run: ../../../b2 toolset=$TOOLSET cxxstd=14,17,2a + run: ../../../b2 toolset=$TOOLSET cxxstd=${{ matrix.cxxstd }} working-directory: ../boost-root/libs/graph/test macos: runs-on: macos-latest @@ -62,8 +61,9 @@ jobs: fail-fast: false matrix: toolset: [ clang ] + cxxstd: [ 14, 17, 20 ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@master with: fetch-depth: '0' - uses: mstachniuk/ci-skip@v1 @@ -89,51 +89,10 @@ jobs: run: ./b2 headers working-directory: ../boost-root - name: Config info - run: ../../../b2 print_config_info toolset=${{ matrix.toolset }} cxxstd=14,17,2a - working-directory: ../boost-root/libs/config/test - - name: Test - run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=14,17,2a define=CI_SUPPRESS_KNOWN_ISSUES - working-directory: ../boost-root/libs/graph/test - windows_msvc_14_2: - runs-on: windows-2019 - defaults: - run: - shell: cmd - strategy: - fail-fast: false - matrix: - toolset: [ msvc-14.2 ] - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: '0' - - uses: mstachniuk/ci-skip@v1 - with: - commit-filter: '[skip ci];[ci skip];[CI SKIP];[SKIP CI];***CI SKIP***;***SKIP CI***;[apple];[Apple];[APPLE];[linux];[Linux];[LINUX]' - commit-filter-separator: ';' - fail-fast: true - - name: Checkout main boost - run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root - - name: Update tools/boostdep - run: git submodule update --init tools/boostdep - working-directory: ../boost-root - - name: Copy files - run: xcopy /s /e /q %GITHUB_WORKSPACE% libs\graph - working-directory: ../boost-root - - name: Install deps - run: python tools/boostdep/depinst/depinst.py graph - working-directory: ../boost-root - - name: Bootstrap - run: bootstrap - working-directory: ../boost-root - - name: Generate headers - run: b2 headers - working-directory: ../boost-root - - name: Config info - run: ..\..\..\b2 print_config_info cxxstd=14,17,20 address-model=64 toolset=msvc-14.2 + run: ../../../b2 print_config_info toolset=${{ matrix.toolset }} cxxstd=${{ matrix.cxxstd }} working-directory: ../boost-root/libs/config/test - name: Test - run: ..\..\..\b2 --hash address-model=64 cxxstd=14,17,20 toolset=msvc-14.2 + run: ../../../b2 toolset=${{ matrix.toolset }} cxxstd=${{ matrix.cxxstd }} define=CI_SUPPRESS_KNOWN_ISSUES working-directory: ../boost-root/libs/graph/test windows_msvc_14_3: runs-on: windows-2022 @@ -182,10 +141,8 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - os: ubuntu-22.04 - os: ubuntu-24.04 - - os: macos-13 - os: macos-14 - os: macos-15 @@ -231,10 +188,8 @@ jobs: fail-fast: false matrix: include: - - os: ubuntu-20.04 - os: ubuntu-22.04 - os: ubuntu-24.04 - - os: macos-13 - os: macos-14 - os: macos-15 @@ -290,8 +245,8 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - os: windows-2022 + - os: windows-2025 runs-on: ${{matrix.os}} @@ -339,8 +294,8 @@ jobs: fail-fast: false matrix: include: - - os: windows-2019 - os: windows-2022 + - os: windows-2025 runs-on: ${{matrix.os}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e294eb5b..df5c57aed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # 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) +cmake_minimum_required(VERSION 3.8...3.16) project(boost_graph VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) @@ -22,7 +22,6 @@ target_link_libraries(boost_graph Boost::array Boost::assert Boost::bimap - Boost::bind Boost::concept_check Boost::config Boost::container_hash @@ -38,6 +37,7 @@ target_link_libraries(boost_graph Boost::move Boost::mpl Boost::multi_index + Boost::multiprecision Boost::optional Boost::parameter Boost::preprocessor diff --git a/build.jam b/build.jam new file mode 100644 index 000000000..6b5a46338 --- /dev/null +++ b/build.jam @@ -0,0 +1,62 @@ +# Copyright René Ferdinand Rivera Morell 2024 +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +require-b2 5.2 ; + +constant boost_dependencies : + /boost/algorithm//boost_algorithm + /boost/any//boost_any + /boost/array//boost_array + /boost/assert//boost_assert + /boost/bimap//boost_bimap + /boost/bind//boost_bind + /boost/concept_check//boost_concept_check + /boost/config//boost_config + /boost/container_hash//boost_container_hash + /boost/conversion//boost_conversion + /boost/core//boost_core + /boost/detail//boost_detail + /boost/foreach//boost_foreach + /boost/function//boost_function + /boost/integer//boost_integer + /boost/iterator//boost_iterator + /boost/lexical_cast//boost_lexical_cast + /boost/math//boost_math_tr1 + /boost/move//boost_move + /boost/mpl//boost_mpl + /boost/multi_index//boost_multi_index + /boost/multiprecision//boost_multiprecision + /boost/optional//boost_optional + /boost/parameter//boost_parameter + /boost/preprocessor//boost_preprocessor + /boost/property_map//boost_property_map + /boost/property_tree//boost_property_tree + /boost/random//boost_random + /boost/range//boost_range + /boost/serialization//boost_serialization + /boost/smart_ptr//boost_smart_ptr + /boost/spirit//boost_spirit + /boost/static_assert//boost_static_assert + /boost/throw_exception//boost_throw_exception + /boost/tti//boost_tti + /boost/tuple//boost_tuple + /boost/type_traits//boost_type_traits + /boost/typeof//boost_typeof + /boost/unordered//boost_unordered + /boost/utility//boost_utility + /boost/xpressive//boost_xpressive ; + +project /boost/graph + ; + +explicit + [ alias boost_graph : build//boost_graph ] + [ alias all : boost_graph example test ] + ; + +call-if : boost-library graph + : install boost_graph + ; + diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index 9c32f9cc9..b213e5498 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -6,9 +6,15 @@ import mpi ; -project boost/graph - : requirements ../src +constant boost_dependencies_private : + /boost/regex//boost_regex + ; + +project + : common-requirements ../include $(boost_dependencies) + : requirements ../src $(boost_dependencies_private) : source-location ../src + : usage-requirements BOOST_GRAPH_NO_LIB=1 ; lib boost_graph @@ -24,5 +30,3 @@ lib boost_graph : : ; - -boost-install boost_graph ; diff --git a/doc/grid_graph.html b/doc/grid_graph.html index 261dd57cf..053ad115d 100644 --- a/doc/grid_graph.html +++ b/doc/grid_graph.html @@ -69,7 +69,7 @@

Overview

Defined in boost/graph/grid_graph.hpp - with all functions in the boost namespace. A simple examples of creating and iterating over a grid_graph is available here libs/graph/example/grid_graph_example.cpp. An example of adding properties to a grid_graph is also available libs/graph/example/grid_graph_properties.cpp + with all functions in the boost namespace. A simple examples of creating and iterating over a grid_graph is available here libs/graph/example/grid_graph_example.cpp. An example of adding properties to a grid_graph is also available libs/graph/example/grid_graph_properties.cpp

Template Parameters

diff --git a/doc/r_c_shortest_paths.html b/doc/r_c_shortest_paths.html index 9d560eb0a..98b6cc26d 100644 --- a/doc/r_c_shortest_paths.html +++ b/doc/r_c_shortest_paths.html @@ -329,6 +329,11 @@

DominanceFunction

+ + + @@ -353,7 +358,7 @@

DominanceFunction

+vis.on_enter_loop(const Queue& queue, const Graph& g ) +
vis.on_label_popped( const Label& l, const Graph& g )
-See the description of the Label concept for the interface of a Label. See the algorithm description for information on when these functions are called. +Note that on_enter_loop returns a boolean that signals whether the main loop should continue (see the default_r_c_shortest_paths_visitor in the source code for inspiration). See the description of the Label concept for the interface of a Label. See the algorithm description for information on when these functions are called.

Functions Description

diff --git a/example/Jamfile.v2 b/example/Jamfile.v2 index e316a1914..1adf5c853 100644 --- a/example/Jamfile.v2 +++ b/example/Jamfile.v2 @@ -3,12 +3,17 @@ # Distributed under the Boost Software License, Version 1.0. (See accompanying # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -import ../../config/checks/config : requires ; +require-b2 5.0.1 ; +import-search /boost/config/checks ; + +import config : requires ; import modules ; import path ; path-constant TEST_DIR : . ; +project : requirements /boost/graph//boost_graph ; + run accum-compile-times.cpp : $(TEST_DIR)/makefile-dependencies.dat $(TEST_DIR)/makefile-target-names.dat $(TEST_DIR)/target-compile-costs.dat ; exe actor_clustering : actor_clustering.cpp ; run adj_list_ra_edgelist.cpp ; @@ -75,15 +80,15 @@ run filtered_graph.cpp ; run filtered_graph_edge_range.cpp ; run filtered_vec_as_graph.cpp ; run filtered-copy-example.cpp ; -exe fr_layout : fr_layout.cpp : [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ; +exe fr_layout : fr_layout.cpp /boost/timer//boost_timer : [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ; run gerdemann.cpp ; run graph.cpp ; run graph_as_tree.cpp ; run graph_property.cpp ; run graph-assoc-types.cpp ; run graph-property-iter-eg.cpp ; -run graph-thingie.cpp ../build//boost_graph ; -run graphviz.cpp ../build//boost_graph : $(TEST_DIR)/graphviz_example.dot ; +run graph-thingie.cpp /boost/graph//boost_graph ; +run graphviz.cpp /boost/graph//boost_graph : $(TEST_DIR)/graphviz_example.dot ; run grid_graph_example.cpp ; run grid_graph_properties.cpp ; exe hawick_circuits : hawick_circuits.cpp ; @@ -114,7 +119,7 @@ exe mean_geodesic : mean_geodesic.cpp ; exe minimum_degree_ordering : minimum_degree_ordering.cpp ; run modify_graph.cpp ; run neighbor_bfs.cpp ; -run ospf-example.cpp ../build//boost_graph : $(TEST_DIR)/figs/ospf-graph.dot $(TEST_DIR)/figs/ospf-sptree.dot $(TEST_DIR)/routing-table.dat ; +run ospf-example.cpp /boost/graph//boost_graph : $(TEST_DIR)/figs/ospf-graph.dot $(TEST_DIR)/figs/ospf-sptree.dot $(TEST_DIR)/routing-table.dat ; run parallel-compile-time.cpp : $(TEST_DIR)/makefile-dependencies.dat $(TEST_DIR)/makefile-target-names.dat $(TEST_DIR)/target-compile-costs.dat ; run planar_face_traversal.cpp ; run prim-example.cpp ; @@ -129,7 +134,7 @@ run put-get-helper-eg.cpp ; run quick_tour.cpp ; run quick-tour.cpp ; run r_c_shortest_paths_example.cpp ; -run read_graphviz.cpp ../build//boost_graph ; +run read_graphviz.cpp /boost/graph//boost_graph ; exe read_write_dimacs : read_write_dimacs-eg.cpp ; run remove_edge_if_bidir.cpp ; run remove_edge_if_dir.cpp ; @@ -208,7 +213,7 @@ explicit girth ; #run edge-connectivity.cpp ; # # These compile, but still use the old graphviz interface and die and runtime: -# run strong_components.cpp ../build//boost_graph ; +# run strong_components.cpp /boost/graph//boost_graph ; # diff --git a/example/accum-compile-times.cpp b/example/accum-compile-times.cpp index e220129e9..0468fcee2 100644 --- a/example/accum-compile-times.cpp +++ b/example/accum-compile-times.cpp @@ -35,25 +35,25 @@ BOOST_INSTALL_PROPERTY(vertex, compile_cost); using namespace boost; -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - listS, // Store vertex set in a std::list - directedS, // The file dependency graph is directed - // vertex properties - property< vertex_name_t, std::string, - property< vertex_compile_cost_t, float, - property< vertex_distance_t, float, - property< vertex_color_t, default_color_type > > > >, - // an edge property - property< edge_weight_t, float > > - file_dep_graph2; +using file_dep_graph2 + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + listS, // Store vertex set in a std::list + directedS, // The file dependency graph is directed + // vertex properties + property< vertex_name_t, std::string, + property< vertex_compile_cost_t, float, + property< vertex_distance_t, float, + property< vertex_color_t, default_color_type > > > >, + // an edge property + property< edge_weight_t, float > >; -typedef graph_traits< file_dep_graph2 >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph2 >::edge_descriptor edge_t; +using vertex_t = graph_traits< file_dep_graph2 >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph2 >::edge_descriptor; int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph2 >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph2 >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 diff --git a/example/actor_clustering.cpp b/example/actor_clustering.cpp index f23f7e3b9..83da433f8 100644 --- a/example/actor_clustering.cpp +++ b/example/actor_clustering.cpp @@ -34,11 +34,10 @@ struct Actor int id; }; -typedef adjacency_list< vecS, vecS, undirectedS, Actor, - property< edge_centrality_t, double > > - ActorGraph; -typedef graph_traits< ActorGraph >::vertex_descriptor Vertex; -typedef graph_traits< ActorGraph >::edge_descriptor Edge; +using ActorGraph = adjacency_list< vecS, vecS, undirectedS, Actor, + property< edge_centrality_t, double > >; +using Vertex = graph_traits< ActorGraph >::vertex_descriptor; +using Edge = graph_traits< ActorGraph >::edge_descriptor; void load_actor_graph(std::istream& in, ActorGraph& g) { @@ -50,7 +49,7 @@ void load_actor_graph(std::istream& in, ActorGraph& g) std::vector< Vertex > actors_in_movie; // Map from the actor numbers on this line to the actor vertices - typedef tokenizer< char_separator< char > > Tok; + using Tok = tokenizer< char_separator< char > >; Tok tok(line, char_separator< char >(" ")); for (auto const & id : tok) { @@ -101,7 +100,7 @@ std::ostream& write_pajek_graph(std::ostream& out, const Graph& g, class actor_clustering_threshold : public bc_clustering_threshold< double > { - typedef bc_clustering_threshold< double > inherited; + using inherited = bc_clustering_threshold< double >; public: actor_clustering_threshold( diff --git a/example/adj_list_ra_edgelist.cpp b/example/adj_list_ra_edgelist.cpp index d6380efae..13a1de1a8 100644 --- a/example/adj_list_ra_edgelist.cpp +++ b/example/adj_list_ra_edgelist.cpp @@ -14,12 +14,11 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, bidirectionalS, no_property, - property< int, edge_weight_t >, no_property, vecS > - Graph; + using Graph = adjacency_list< vecS, vecS, bidirectionalS, no_property, + property< int, edge_weight_t >, no_property, vecS >; const std::size_t n = 3; - typedef std::pair< std::size_t, std::size_t > E; + using E = std::pair< std::size_t, std::size_t >; E edge_array[] = { E(0, 1), E(0, 2), E(0, 1) }; const std::size_t m = sizeof(edge_array) / sizeof(E); Graph g(edge_array, edge_array + m, n); diff --git a/example/adjacency_list.cpp b/example/adjacency_list.cpp index b8a984d66..82786c578 100644 --- a/example/adjacency_list.cpp +++ b/example/adjacency_list.cpp @@ -54,9 +54,8 @@ int main(int, char*[]) using namespace boost; using namespace std; - typedef adjacency_list< vecS, listS, undirectedS, VertexProperties, - EdgeProperties > - Graph; + using Graph = adjacency_list< vecS, listS, undirectedS, VertexProperties, + EdgeProperties >; const int V = 5; Graph g(V); diff --git a/example/adjacency_list_io.cpp b/example/adjacency_list_io.cpp index bfc0280c5..18bbc4832 100644 --- a/example/adjacency_list_io.cpp +++ b/example/adjacency_list_io.cpp @@ -37,7 +37,8 @@ struct n1_t { num = 23063 }; - typedef vertex_property_tag kind; + + using kind = vertex_property_tag; }; struct n2_t { @@ -45,7 +46,8 @@ struct n2_t { num = 23062 }; - typedef vertex_property_tag kind; + + using kind = vertex_property_tag; }; struct n3_t { @@ -53,11 +55,11 @@ struct n3_t { num = 23061 }; - typedef vertex_property_tag kind; + + using kind = vertex_property_tag; }; -typedef property< n1_t, int, - property< n2_t, double, property< n3_t, MyStruct > > > - VertexProperty; +using VertexProperty = property< n1_t, int, + property< n2_t, double, property< n3_t, MyStruct > > >; //====== edge properties struct e1_t @@ -66,18 +68,18 @@ struct e1_t { num = 23064 }; - typedef edge_property_tag kind; + + using kind = edge_property_tag; }; -typedef property< e1_t, double > EdgeProperty; +using EdgeProperty = property< e1_t, double >; //===== graph types -typedef adjacency_list< vecS, listS, directedS, no_property, no_property > - Graph1; +using Graph1 + = adjacency_list< vecS, listS, directedS, no_property, no_property >; -typedef adjacency_list< setS, setS, bidirectionalS, VertexProperty, - EdgeProperty > - Graph2; +using Graph2 = adjacency_list< setS, setS, bidirectionalS, VertexProperty, + EdgeProperty >; int main() { @@ -103,7 +105,7 @@ int main() // read Graph2, incomplete data in a different order. Write it diffently. Graph2 g31; std::ifstream readFile31("data3.txt"); - typedef property< n3_t, MyStruct, property< n1_t, int > > readNodeProp; + using readNodeProp = property< n3_t, MyStruct, property< n1_t, int > >; readFile31 >> read(g31, readNodeProp(), EdgeProperty()); std::cout << "graph g31 from file data3.txt:\n" << write(g31, property< n3_t, MyStruct >(), EdgeProperty()) diff --git a/example/adjacency_matrix.cpp b/example/adjacency_matrix.cpp index 4f36ead98..9ee907cc0 100644 --- a/example/adjacency_matrix.cpp +++ b/example/adjacency_matrix.cpp @@ -28,7 +28,7 @@ int main() // A directed graph - typedef adjacency_matrix< directedS > Graph; + using Graph = adjacency_matrix< directedS >; Graph g(N); add_edge(B, C, g); add_edge(B, F, g); @@ -52,7 +52,7 @@ int main() // An undirected graph - typedef adjacency_matrix< undirectedS > UGraph; + using UGraph = adjacency_matrix< undirectedS >; UGraph ug(N); add_edge(B, C, ug); add_edge(B, F, ug); diff --git a/example/astar-cities.cpp b/example/astar-cities.cpp index 7c615ac9d..42d0d016a 100644 --- a/example/astar-cities.cpp +++ b/example/astar-cities.cpp @@ -30,7 +30,7 @@ struct location { float y, x; // lat, long }; -typedef float cost; +using cost = float; template < class Name, class LocMap > class city_writer { @@ -82,7 +82,7 @@ template < class Graph, class CostType, class LocMap > class distance_heuristic : public astar_heuristic< Graph, CostType > { public: - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; distance_heuristic(LocMap l, Vertex goal) : m_location(l), m_goal(goal) {} CostType operator()(Vertex u) { @@ -120,13 +120,12 @@ int main(int argc, char** argv) { // specify some types - typedef adjacency_list< listS, vecS, undirectedS, no_property, - property< edge_weight_t, cost > > - mygraph_t; - typedef property_map< mygraph_t, edge_weight_t >::type WeightMap; - typedef mygraph_t::vertex_descriptor vertex; - typedef mygraph_t::edge_descriptor edge_descriptor; - typedef std::pair< int, int > edge; + using mygraph_t = adjacency_list< listS, vecS, undirectedS, no_property, + property< edge_weight_t, cost > >; + using WeightMap = property_map< mygraph_t, edge_weight_t >::type; + using vertex = mygraph_t::vertex_descriptor; + using edge_descriptor = mygraph_t::edge_descriptor; + using edge = std::pair< int, int >; // specify data enum nodes diff --git a/example/astar_maze.cpp b/example/astar_maze.cpp index 089b569f7..92701d60a 100644 --- a/example/astar_maze.cpp +++ b/example/astar_maze.cpp @@ -45,18 +45,18 @@ boost::mt19937 random_generator; // Distance traveled in the maze -typedef double distance; +using distance = double; #define GRID_RANK 2 -typedef boost::grid_graph< GRID_RANK > grid; -typedef boost::graph_traits< grid >::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits< grid >::vertices_size_type vertices_size_type; +using grid = boost::grid_graph< GRID_RANK >; +using vertex_descriptor = boost::graph_traits< grid >::vertex_descriptor; +using vertices_size_type = boost::graph_traits< grid >::vertices_size_type; // A hash function for vertices. struct vertex_hash { - typedef vertex_descriptor argument_type; - typedef std::size_t result_type; + using argument_type = vertex_descriptor; + using result_type = std::size_t; std::size_t operator()(vertex_descriptor const& u) const { std::size_t seed = 0; @@ -66,9 +66,9 @@ struct vertex_hash } }; -typedef boost::unordered_set< vertex_descriptor, vertex_hash > vertex_set; -typedef boost::vertex_subset_complement_filter< grid, vertex_set >::type - filtered_grid; +using vertex_set = boost::unordered_set< vertex_descriptor, vertex_hash >; +using filtered_grid + = boost::vertex_subset_complement_filter< grid, vertex_set >::type; // A searchable maze // @@ -190,14 +190,13 @@ bool maze::solve() { boost::static_property_map< distance > weight(1); // The predecessor map is a vertex-to-vertex mapping. - typedef boost::unordered_map< vertex_descriptor, vertex_descriptor, - vertex_hash > - pred_map; + using pred_map = boost::unordered_map< vertex_descriptor, vertex_descriptor, + vertex_hash >; pred_map predecessor; boost::associative_property_map< pred_map > pred_pmap(predecessor); // The distance map is a vertex-to-distance mapping. - typedef boost::unordered_map< vertex_descriptor, distance, vertex_hash > - dist_map; + using dist_map + = boost::unordered_map< vertex_descriptor, distance, vertex_hash >; dist_map distance; boost::associative_property_map< dist_map > dist_pmap(distance); diff --git a/example/bellman-example.cpp b/example/bellman-example.cpp index 2de9c3529..57c5707d2 100644 --- a/example/bellman-example.cpp +++ b/example/bellman-example.cpp @@ -56,14 +56,14 @@ int main() N }; char name[] = { 'u', 'v', 'x', 'y', 'z' }; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; const int n_edges = 10; E edge_array[] = { E(u, y), E(u, x), E(u, v), E(v, u), E(x, y), E(x, v), E(y, v), E(y, z), E(z, u), E(z, x) }; int weight[n_edges] = { -4, 8, 5, -2, 9, -3, 7, 2, 6, 7 }; - typedef adjacency_list< vecS, vecS, directedS, no_property, EdgeProperties > - Graph; + using Graph + = adjacency_list< vecS, vecS, directedS, no_property, EdgeProperties >; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor Graph g(N); diff --git a/example/bellman-ford-internet.cpp b/example/bellman-ford-internet.cpp index a761373d3..59438e923 100644 --- a/example/bellman-ford-internet.cpp +++ b/example/bellman-ford-internet.cpp @@ -25,19 +25,17 @@ int main() H, n_vertices }; - const int n_edges = 11; - typedef std::pair< int, int > Edge; + using Edge = std::pair< int, int >; // The list of connections between routers stored in an array. - Edge edges[] = { Edge(A, B), Edge(A, C), Edge(B, D), Edge(B, E), Edge(C, E), - Edge(C, F), Edge(D, H), Edge(D, E), Edge(E, H), Edge(F, G), + Edge edges[] = { Edge(A, B), Edge(A, C), Edge(B, D), Edge(B, E), + Edge(C, E), Edge(C, F), Edge(D, H), Edge(D, E), Edge(E, H), Edge(F, G), Edge(G, H) }; // Specify the graph type and declare a graph object - typedef edge_list< Edge*, Edge, std::ptrdiff_t, - std::random_access_iterator_tag > - Graph; - Graph g(edges, edges + n_edges); + using Graph = edge_list< Edge*, Edge, std::ptrdiff_t, + std::random_access_iterator_tag >; + Graph g(std::begin(edges), std::end(edges)); // The transmission delay values for each edge. float delay[] = { 5.0, 1.0, 1.3, 3.0, 10.0, 2.0, 6.3, 0.4, 1.3, 1.2, 0.5 }; diff --git a/example/bfs-example.cpp b/example/bfs-example.cpp index c42bef153..1d783c59c 100644 --- a/example/bfs-example.cpp +++ b/example/bfs-example.cpp @@ -16,7 +16,7 @@ using namespace boost; template < typename TimeMap > class bfs_time_visitor : public default_bfs_visitor { - typedef typename property_traits< TimeMap >::value_type T; + using T = typename property_traits< TimeMap >::value_type; public: bfs_time_visitor(TimeMap tmap, T& t) : m_timemap(tmap), m_time(t) {} @@ -33,7 +33,7 @@ int main() { using namespace boost; // Select the graph type we wish to use - typedef adjacency_list< vecS, vecS, undirectedS > graph_t; + using graph_t = adjacency_list< vecS, vecS, undirectedS >; // Set up the vertex IDs and names enum { @@ -49,7 +49,7 @@ int main() }; const char* name = "rstuvwxy"; // Specify the edges in the graph - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; // Create the graph object @@ -60,18 +60,17 @@ int main() for (std::size_t j = 0; j < n_edges; ++j) add_edge(edge_array[j].first, edge_array[j].second, g); #else - typedef graph_traits< graph_t >::vertices_size_type v_size_t; + using v_size_t = graph_traits< graph_t >::vertices_size_type; graph_t g(edge_array, edge_array + n_edges, v_size_t(N)); #endif // Typedefs - typedef graph_traits< graph_t >::vertices_size_type Size; + using Size = graph_traits< graph_t >::vertices_size_type; // a vector to hold the discover time property for each vertex std::vector< Size > dtime(num_vertices(g)); - typedef iterator_property_map< std::vector< Size >::iterator, - property_map< graph_t, vertex_index_t >::const_type > - dtime_pm_type; + using dtime_pm_type = iterator_property_map< std::vector< Size >::iterator, + property_map< graph_t, vertex_index_t >::const_type >; dtime_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); Size time = 0; diff --git a/example/bfs-example2.cpp b/example/bfs-example2.cpp index 5bd66e39a..1f2096b85 100644 --- a/example/bfs-example2.cpp +++ b/example/bfs-example2.cpp @@ -17,7 +17,7 @@ using namespace boost; template < typename TimeMap > class bfs_time_visitor : public default_bfs_visitor { - typedef typename property_traits< TimeMap >::value_type T; + using T = typename property_traits< TimeMap >::value_type; public: bfs_time_visitor(TimeMap tmap, T& t) : m_timemap(tmap), m_time(t) {} @@ -41,7 +41,7 @@ int main() { using namespace boost; // Select the graph type we wish to use - typedef adjacency_list< listS, listS, undirectedS, VertexProps > graph_t; + using graph_t = adjacency_list< listS, listS, undirectedS, VertexProps >; // Set up the vertex IDs and names enum { @@ -57,7 +57,7 @@ int main() }; const char* name = "rstuvwxy"; // Specify the edges in the graph - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edge_array[] = { E(r, s), E(r, v), E(s, w), E(w, r), E(w, t), E(w, x), E(x, t), E(t, u), E(x, y), E(u, y) }; // Create the graph object @@ -71,16 +71,16 @@ int main() for (std::size_t j = 0; j < n_edges; ++j) add_edge(verts[edge_array[j].first], verts[edge_array[j].second], g); #else - typedef graph_traits< graph_t >::vertices_size_type v_size_t; + using v_size_t = graph_traits< graph_t >::vertices_size_type; graph_t g(edge_array, edge_array + n_edges, v_size_t(N)); #endif // Typedefs - typedef graph_traits< graph_t >::vertices_size_type Size; + using Size = graph_traits< graph_t >::vertices_size_type; Size time = 0; - typedef property_map< graph_t, std::size_t VertexProps::* >::type - dtime_map_t; + using dtime_map_t + = property_map< graph_t, std::size_t VertexProps::* >::type; auto dtime_map = get(&VertexProps::discover_time, g); bfs_time_visitor< dtime_map_t > vis(dtime_map, time); breadth_first_search( @@ -88,9 +88,8 @@ int main() // a vector to hold the discover time property for each vertex std::vector< Size > dtime(num_vertices(g)); - typedef iterator_property_map< std::vector< Size >::iterator, - property_map< graph_t, unsigned int VertexProps::* >::type > - dtime_pm_type; + using dtime_pm_type = iterator_property_map< std::vector< Size >::iterator, + property_map< graph_t, unsigned int VertexProps::* >::type >; graph_traits< graph_t >::vertex_iterator vi, vi_end; std::size_t c = 0; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi, ++c) diff --git a/example/bfs-name-printer.cpp b/example/bfs-name-printer.cpp index 5b19e9c01..b1c8ea6de 100644 --- a/example/bfs-name-printer.cpp +++ b/example/bfs-name-printer.cpp @@ -74,7 +74,7 @@ struct EP int main() { - typedef adjacency_list< listS, vecS, directedS, VP, EP > graph_t; + using graph_t = adjacency_list< listS, vecS, directedS, VP, EP >; graph_t g; auto name_map = get(&VP::name, g); @@ -82,7 +82,7 @@ int main() build_router_network(g, name_map, delay_map); - typedef property_map< graph_t, char VP::* >::type VertexNameMap; + using VertexNameMap = property_map< graph_t, char VP::* >::type; auto a = *vertices(g).first; bfs_name_printer< VertexNameMap > vis(name_map); std::cout << "BFS vertex discover order: "; diff --git a/example/bfs.cpp b/example/bfs.cpp index 09d7b0947..5ddfc0eb2 100644 --- a/example/bfs.cpp +++ b/example/bfs.cpp @@ -70,7 +70,7 @@ template < class NewGraph, class Tag > struct graph_copier : public boost::base_visitor< graph_copier< NewGraph, Tag > > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) {} @@ -91,13 +91,12 @@ inline graph_copier< NewGraph, Tag > copy_graph(NewGraph& g, Tag) int main(int, char*[]) { - typedef boost::adjacency_list< boost::mapS, boost::vecS, + using Graph = boost::adjacency_list< boost::mapS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_color_t, boost::default_color_type, boost::property< boost::vertex_degree_t, int, boost::property< boost::vertex_in_degree_t, int, - boost::property< boost::vertex_out_degree_t, int > > > > > - Graph; + boost::property< boost::vertex_out_degree_t, int > > > > >; Graph G(5); boost::add_edge(0, 2, G); @@ -112,7 +111,7 @@ int main(int, char*[]) boost::add_edge(4, 0, G); boost::add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; Graph G_copy(5); // Array to store predecessor (parent) of each vertex. This will be @@ -120,7 +119,7 @@ int main(int, char*[]) std::vector< Vertex > p(boost::num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector< Vertex >::value_type* Piter; + using Piter = std::vector< Vertex >::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as diff --git a/example/bfs_neighbor.cpp b/example/bfs_neighbor.cpp index 5408246df..6994fa421 100644 --- a/example/bfs_neighbor.cpp +++ b/example/bfs_neighbor.cpp @@ -65,7 +65,7 @@ template < class NewGraph, class Tag > struct graph_copier : public boost::base_visitor< graph_copier< NewGraph, Tag > > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) {} @@ -86,13 +86,12 @@ inline graph_copier< NewGraph, Tag > copy_graph(NewGraph& g, Tag) int main(int, char*[]) { - typedef boost::adjacency_list< boost::mapS, boost::vecS, + using Graph = boost::adjacency_list< boost::mapS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_color_t, boost::default_color_type, boost::property< boost::vertex_degree_t, int, boost::property< boost::vertex_in_degree_t, int, - boost::property< boost::vertex_out_degree_t, int > > > > > - Graph; + boost::property< boost::vertex_out_degree_t, int > > > > >; Graph G(5); boost::add_edge(0, 2, G); @@ -107,14 +106,14 @@ int main(int, char*[]) boost::add_edge(4, 0, G); boost::add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; // Array to store predecessor (parent) of each vertex. This will be // used as a Decorator (actually, its iterator will be). std::vector< Vertex > p(boost::num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector< Vertex >::value_type* Piter; + using Piter = std::vector< Vertex >::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as diff --git a/example/biconnected_components.cpp b/example/biconnected_components.cpp index 17380fd5d..1efbb5236 100644 --- a/example/biconnected_components.cpp +++ b/example/biconnected_components.cpp @@ -21,17 +21,16 @@ struct edge_component_t { num = 555 }; - typedef edge_property_tag kind; + using kind = edge_property_tag; } edge_component; } int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_component_t, std::size_t > > - graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_t; + using graph_t = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_component_t, std::size_t > >; + using vertex_t = graph_traits< graph_t >::vertex_descriptor; graph_t g(9); add_edge(0, 5, g); add_edge(0, 1, g); diff --git a/example/bipartite_example.cpp b/example/bipartite_example.cpp index 99ac316ff..9c2c78c0c 100644 --- a/example/bipartite_example.cpp +++ b/example/bipartite_example.cpp @@ -20,7 +20,7 @@ using namespace boost; template < typename Graph > void print_bipartite(const Graph& g) { - typedef graph_traits< Graph > traits; + using traits = graph_traits< Graph >; typename traits::vertex_iterator vertex_iter, vertex_end; /// Most simple interface just tests for bipartiteness. @@ -29,11 +29,11 @@ template < typename Graph > void print_bipartite(const Graph& g) if (bipartite) { - typedef std::vector< default_color_type > partition_t; - typedef - typename property_map< Graph, vertex_index_t >::type index_map_t; - typedef iterator_property_map< partition_t::iterator, index_map_t > - partition_map_t; + using partition_t = std::vector< default_color_type >; + using index_map_t = + typename property_map< Graph, vertex_index_t >::type; + using partition_map_t + = iterator_property_map< partition_t::iterator, index_map_t >; partition_t partition(num_vertices(g)); partition_map_t partition_map(partition.begin(), get(vertex_index, g)); @@ -57,8 +57,8 @@ template < typename Graph > void print_bipartite(const Graph& g) } else { - typedef std::vector< typename traits::vertex_descriptor > - vertex_vector_t; + using vertex_vector_t + = std::vector< typename traits::vertex_descriptor >; vertex_vector_t odd_cycle; /// A third interface yields an odd-cycle if the graph is not bipartite. @@ -76,8 +76,8 @@ template < typename Graph > void print_bipartite(const Graph& g) int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS > vector_graph_t; - typedef std::pair< int, int > E; + using vector_graph_t = adjacency_list< vecS, vecS, undirectedS >; + using E = std::pair< int, int >; /** * Create the graph drawn below. diff --git a/example/boost_web_graph.cpp b/example/boost_web_graph.cpp index cae0cfaba..3cc681f40 100644 --- a/example/boost_web_graph.cpp +++ b/example/boost_web_graph.cpp @@ -47,7 +47,7 @@ class print_tree_visitor : public boost::dfs_visitor<> void discover_vertex( typename boost::graph_traits< Graph >::vertex_descriptor v, Graph&) { - typedef typename boost::property_traits< DistanceMap >::value_type Dist; + using Dist = typename boost::property_traits< DistanceMap >::value_type; // indentation based on depth for (Dist i = 0; i < distance[v]; ++i) std::cout << " "; @@ -80,17 +80,16 @@ int main(int argc, const char** argv) //=========================================================================== // Declare the graph type and object, and some property maps. - typedef adjacency_list< vecS, vecS, directedS, + using Graph = adjacency_list< vecS, vecS, directedS, property< vertex_name_t, std::string, property< vertex_color_t, default_color_type > >, - property< edge_name_t, std::string, property< edge_weight_t, int > > > - Graph; + property< edge_name_t, std::string, property< edge_weight_t, int > > >; - typedef graph_traits< Graph > Traits; - typedef Traits::vertex_descriptor Vertex; - typedef Traits::edge_descriptor Edge; + using Traits = graph_traits< Graph >; + using Vertex = Traits::vertex_descriptor; + using Edge = Traits::edge_descriptor; - typedef std::map< std::string, Vertex > NameVertexMap; + using NameVertexMap = std::map< std::string, Vertex >; NameVertexMap name2vertex; Graph g; @@ -149,8 +148,8 @@ int main(int argc, const char** argv) //=========================================================================== // Calculate the diameter of the graph. - typedef Traits::vertices_size_type size_type; - typedef std::vector< size_type > IntVector; + using size_type = Traits::vertices_size_type; + using IntVector = std::vector< size_type >; // Create N x N matrix for storing the shortest distances // between each vertex. Initialize all distances to zero. std::vector< IntVector > d_matrix( diff --git a/example/boykov_kolmogorov-eg.cpp b/example/boykov_kolmogorov-eg.cpp index 67b1bfcde..0fb82870c 100644 --- a/example/boykov_kolmogorov-eg.cpp +++ b/example/boykov_kolmogorov-eg.cpp @@ -70,19 +70,17 @@ int main() { using namespace boost; - typedef adjacency_list_traits< vecS, vecS, directedS > Traits; - typedef adjacency_list< vecS, vecS, directedS, + using Traits = adjacency_list_traits< vecS, vecS, directedS >; + using Graph = adjacency_list< vecS, vecS, directedS, property< vertex_name_t, std::string, property< vertex_index_t, long, property< vertex_color_t, boost::default_color_type, property< vertex_distance_t, long, property< vertex_predecessor_t, Traits::edge_descriptor > > > > >, - property< edge_capacity_t, long, property< edge_residual_capacity_t, long, - property< edge_reverse_t, Traits::edge_descriptor > > > > - Graph; + property< edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; auto capacity = get(edge_capacity, g); diff --git a/example/bron_kerbosch_clique_number.cpp b/example/bron_kerbosch_clique_number.cpp index f8251df43..f21fdcf2d 100644 --- a/example/bron_kerbosch_clique_number.cpp +++ b/example/bron_kerbosch_clique_number.cpp @@ -18,9 +18,9 @@ using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. -typedef undirected_graph<> Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph<>; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; int main(int argc, char* argv[]) { diff --git a/example/bron_kerbosch_print_cliques.cpp b/example/bron_kerbosch_print_cliques.cpp index 21c83b690..f656ffba9 100644 --- a/example/bron_kerbosch_print_cliques.cpp +++ b/example/bron_kerbosch_print_cliques.cpp @@ -42,13 +42,13 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; int main(int argc, char* argv[]) { diff --git a/example/bucket_sorter.cpp b/example/bucket_sorter.cpp index fdc91f88e..9368fbadb 100644 --- a/example/bucket_sorter.cpp +++ b/example/bucket_sorter.cpp @@ -29,10 +29,9 @@ int main() cout << "Number " << i << " is in bucket " << bucket[i] << endl; } - typedef boost::identity_property_map ID; - typedef bucket_sorter< std::size_t, int, vector< std::size_t >::iterator, - ID > - BS; + using ID = boost::identity_property_map; + using BS = bucket_sorter< std::size_t, int, vector< std::size_t >::iterator, + ID >; BS my_bucket_sorter(N, N, bucket.begin()); for (std::size_t ii = 0; ii < N; ii++) diff --git a/example/canonical_ordering.cpp b/example/canonical_ordering.cpp index ffcb96314..87d99011a 100644 --- a/example/canonical_ordering.cpp +++ b/example/canonical_ordering.cpp @@ -21,9 +21,8 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int >, property< edge_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int >, property< edge_index_t, int > >; // Create a maximal planar graph on 6 vertices graph g(6); @@ -52,7 +51,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - typedef std::vector< graph_traits< graph >::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits< graph >::edge_descriptor >; std::vector< vec_t > embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = make_iterator_property_map( @@ -61,8 +60,8 @@ int main(int argc, char** argv) else std::cout << "Input graph is not planar" << std::endl; - typedef std::vector< graph_traits< graph >::vertex_descriptor > - ordering_storage_t; + using ordering_storage_t + = std::vector< graph_traits< graph >::vertex_descriptor >; ordering_storage_t ordering; planar_canonical_ordering(g, diff --git a/example/city_visitor.cpp b/example/city_visitor.cpp index 4b72bf330..f63388047 100644 --- a/example/city_visitor.cpp +++ b/example/city_visitor.cpp @@ -56,7 +56,7 @@ using namespace boost; struct city_arrival : public base_visitor< city_arrival > { city_arrival(string* n) : names(n) {} - typedef on_discover_vertex event_filter; + using event_filter = on_discover_vertex; template < class Vertex, class Graph > inline void operator()(Vertex u, Graph&) { @@ -70,7 +70,7 @@ struct city_arrival : public base_visitor< city_arrival > struct neighbor_cities : public base_visitor< neighbor_cities > { neighbor_cities(string* n) : names(n) {} - typedef on_examine_edge event_filter; + using event_filter = on_examine_edge; template < class Edge, class Graph > inline void operator()(Edge e, Graph& g) { @@ -82,7 +82,7 @@ struct neighbor_cities : public base_visitor< neighbor_cities > struct finish_city : public base_visitor< finish_city > { finish_city(string* n) : names(n) {} - typedef on_finish_vertex event_filter; + using event_filter = on_finish_vertex; template < class Vertex, class Graph > inline void operator()(Vertex u, Graph&) { @@ -113,14 +113,14 @@ int main(int, char*[]) = { "San Jose", "San Francisco", "Los Angeles", "San Diego", "Fresno", "Las Vegas", "Reno", "Sacramento", "Salt Lake City", "Phoenix" }; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edge_array[] = { E(Sacramento, Reno), E(Sacramento, SanFran), E(Reno, SaltLake), E(SanFran, SanJose), E(SanJose, Fresno), E(SanJose, LA), E(LA, LasVegas), E(LA, SanDiego), E(LasVegas, Phoenix) }; /* Create the graph type we want. */ - typedef adjacency_list< vecS, vecS, undirectedS > Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS >; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ has trouble with the edge iterator constructor Graph G(N); diff --git a/example/closeness_centrality.cpp b/example/closeness_centrality.cpp index 9703bf3d3..4181448cb 100644 --- a/example/closeness_centrality.cpp +++ b/example/closeness_centrality.cpp @@ -25,29 +25,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property< Graph, int > DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property< Graph, int >; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map< Edge, int > WeightMap; +using WeightMap = constant_property_map< Edge, int >; // Declare a container and its corresponding property map that // will contain the resulting closeness centralities of each // vertex in the graph. -typedef boost::exterior_vertex_property< Graph, float > ClosenessProperty; -typedef ClosenessProperty::container_type ClosenessContainer; -typedef ClosenessProperty::map_type ClosenessMap; +using ClosenessProperty = boost::exterior_vertex_property< Graph, float >; +using ClosenessContainer = ClosenessProperty::container_type; +using ClosenessMap = ClosenessProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/clustering_coefficient.cpp b/example/clustering_coefficient.cpp index 4c05c2a23..4b64e1f5f 100644 --- a/example/clustering_coefficient.cpp +++ b/example/clustering_coefficient.cpp @@ -23,19 +23,19 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // The clustering property, container, and map define the containment // and abstract accessor for the clustering coefficients of vertices. -typedef exterior_vertex_property< Graph, float > ClusteringProperty; -typedef ClusteringProperty::container_type ClusteringContainer; -typedef ClusteringProperty::map_type ClusteringMap; +using ClusteringProperty = exterior_vertex_property< Graph, float >; +using ClusteringContainer = ClusteringProperty::container_type; +using ClusteringMap = ClusteringProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/components_on_edgelist.cpp b/example/components_on_edgelist.cpp index 233405148..7c0045a1b 100644 --- a/example/components_on_edgelist.cpp +++ b/example/components_on_edgelist.cpp @@ -54,8 +54,8 @@ using boost::tie; int main(int, char*[]) { using namespace boost; - typedef int Index; // ID of a Vertex - typedef pair< Index, Index > Edge; + using Index = int; // ID of a Vertex + using Edge = pair< Index, Index >; const int N = 6; const int E = 4; Edge edgelist[] = { Edge(0, 1), Edge(1, 4), Edge(4, 0), Edge(2, 5) }; diff --git a/example/connected-components.cpp b/example/connected-components.cpp index 396abb3f7..051b47658 100644 --- a/example/connected-components.cpp +++ b/example/connected-components.cpp @@ -14,7 +14,7 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS > Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS >; const int N = 6; Graph G(N); diff --git a/example/connected_components.cpp b/example/connected_components.cpp index 8fd6efc4c..5bb65b33c 100644 --- a/example/connected_components.cpp +++ b/example/connected_components.cpp @@ -40,7 +40,7 @@ int main(int, char*[]) { using namespace boost; { - typedef adjacency_list< vecS, vecS, undirectedS > Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS >; Graph G; add_edge(0, 1, G); diff --git a/example/container_gen.cpp b/example/container_gen.cpp index 55d372a35..fbb61a698 100644 --- a/example/container_gen.cpp +++ b/example/container_gen.cpp @@ -21,24 +21,24 @@ template < class Alloc, class ValueType > struct container_gen< list_with_allocatorS< Alloc >, ValueType > { #ifdef BOOST_NO_CXX11_ALLOCATOR - typedef typename Alloc::template rebind< ValueType >::other Allocator; + using Allocator = typename Alloc::template rebind< ValueType >::other; #else - typedef typename std::allocator_traits::template rebind_alloc Allocator; + using Allocator = typename std::allocator_traits< + Alloc >::template rebind_alloc< ValueType >; #endif - typedef std::list< ValueType, Allocator > type; + using type = std::list< ValueType, Allocator >; }; template < class Alloc > struct parallel_edge_traits< list_with_allocatorS< Alloc > > { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; - } // now you can define a graph using std::list and a specific allocator -typedef boost::adjacency_list< list_with_allocatorS< std::allocator< int > >, - boost::vecS, boost::directedS > - MyGraph; +using MyGraph + = boost::adjacency_list< list_with_allocatorS< std::allocator< int > >, + boost::vecS, boost::directedS >; int main(int, char*[]) { diff --git a/example/copy-example.cpp b/example/copy-example.cpp index 9a0b345d4..a41780725 100644 --- a/example/copy-example.cpp +++ b/example/copy-example.cpp @@ -14,9 +14,8 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, - property< vertex_name_t, char > > - graph_t; + using graph_t = adjacency_list< vecS, vecS, directedS, + property< vertex_name_t, char > >; enum { @@ -36,7 +35,7 @@ int main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; for (int i = 0; i < 12; ++i) diff --git a/example/csr-example.cpp b/example/csr-example.cpp index a471e6997..456ccd824 100644 --- a/example/csr-example.cpp +++ b/example/csr-example.cpp @@ -24,7 +24,7 @@ class WebPage int main() { - typedef std::pair< int, int > E; + using E = std::pair< int, int >; const char* urls[6] = { "http://www.boost.org/libs/graph/doc/index.html", "http://www.boost.org/libs/graph/doc/table_of_contents.html", @@ -37,7 +37,7 @@ int main() E the_edges[] = { E(0, 1), E(0, 2), E(0, 3), E(1, 0), E(1, 3), E(1, 5), E(2, 0), E(2, 5), E(3, 1), E(3, 4), E(4, 1), E(5, 0), E(5, 2) }; - typedef compressed_sparse_row_graph< directedS, WebPage > WebGraph; + using WebGraph = compressed_sparse_row_graph< directedS, WebPage >; WebGraph g(boost::edges_are_sorted, &the_edges[0], &the_edges[0] + sizeof(the_edges) / sizeof(E), 6); diff --git a/example/cuthill_mckee_ordering.cpp b/example/cuthill_mckee_ordering.cpp index 6406e9337..7f0b9a068 100644 --- a/example/cuthill_mckee_ordering.cpp +++ b/example/cuthill_mckee_ordering.cpp @@ -33,14 +33,13 @@ int main(int, char*[]) { using namespace boost; using namespace std; - typedef adjacency_list< vecS, vecS, undirectedS, + using Graph = adjacency_list< vecS, vecS, undirectedS, property< vertex_color_t, default_color_type, - property< vertex_degree_t, int > > > - Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - typedef graph_traits< Graph >::vertices_size_type size_type; + property< vertex_degree_t, int > > >; + using Vertex = graph_traits< Graph >::vertex_descriptor; + using size_type = graph_traits< Graph >::vertices_size_type; - typedef std::pair< std::size_t, std::size_t > Pair; + using Pair = std::pair< std::size_t, std::size_t >; Pair edges[14] = { Pair(0, 3), // a-d Pair(0, 5), // a-f Pair(1, 2), // b-c @@ -57,8 +56,8 @@ int main(int, char*[]) Pair(6, 7) }; // g-h Graph G(10); - for (int i = 0; i < 14; ++i) - add_edge(edges[i].first, edges[i].second, G); + for (auto const& edge : edges) + add_edge(edge.first, edge.second, G); graph_traits< Graph >::vertex_iterator ui, ui_end; @@ -79,8 +78,8 @@ int main(int, char*[]) get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (auto const& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -98,8 +97,8 @@ int main(int, char*[]) get(vertex_degree, G)); cout << "Reverse Cuthill-McKee ordering starting at: " << s << endl; cout << " "; - for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (auto const& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -118,8 +117,8 @@ int main(int, char*[]) cout << "Reverse Cuthill-McKee ordering:" << endl; cout << " "; - for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (auto const& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) diff --git a/example/cycle-file-dep.cpp b/example/cycle-file-dep.cpp index a1d55ef7b..e6d275d49 100644 --- a/example/cycle-file-dep.cpp +++ b/example/cycle-file-dep.cpp @@ -24,14 +24,14 @@ std::istream& operator>>(std::istream& in, std::pair< T, T >& p) } } -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - vecS, // Store vertex set in a std::vector - directedS // The file dependency graph is directed - > - file_dep_graph; +using file_dep_graph + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + vecS, // Store vertex set in a std::vector + directedS // The file dependency graph is directed + >; -typedef graph_traits< file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits< file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph >::edge_descriptor; bool has_cycle_dfs( const file_dep_graph& g, vertex_t u, default_color_type* color) @@ -64,7 +64,7 @@ bool has_cycle(const file_dep_graph& g) int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator< std::pair< size_type, size_type > > input_begin( diff --git a/example/cycle-file-dep2.cpp b/example/cycle-file-dep2.cpp index 678727a22..243cdd8ef 100644 --- a/example/cycle-file-dep2.cpp +++ b/example/cycle-file-dep2.cpp @@ -26,14 +26,14 @@ std::istream& operator>>(std::istream& in, std::pair< T, T >& p) } } -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - vecS, // Store vertex set in a std::vector - directedS // The file dependency graph is directed - > - file_dep_graph; +using file_dep_graph + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + vecS, // Store vertex set in a std::vector + directedS // The file dependency graph is directed + >; -typedef graph_traits< file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits< file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph >::edge_descriptor; template < typename Visitor > void dfs_v1( @@ -103,7 +103,7 @@ bool has_cycle(const file_dep_graph& g) int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator< std::pair< size_type, size_type > > input_begin( diff --git a/example/cycle_ratio_example.cpp b/example/cycle_ratio_example.cpp index 0f73b35f9..c7a295f38 100644 --- a/example/cycle_ratio_example.cpp +++ b/example/cycle_ratio_example.cpp @@ -18,10 +18,9 @@ */ using namespace boost; -typedef adjacency_list< listS, listS, directedS, - property< vertex_index_t, int >, - property< edge_weight_t, double, property< edge_weight2_t, double > > > - grap_real_t; +using grap_real_t + = adjacency_list< listS, listS, directedS, property< vertex_index_t, int >, + property< edge_weight_t, double, property< edge_weight2_t, double > > >; template < typename TG > void gen_rand_graph(TG& g, size_t nV, size_t nE) { @@ -45,8 +44,8 @@ int main(int argc, char* argv[]) using std::endl; const double epsilon = 0.0000001; double min_cr, max_cr; /// Minimum and maximum cycle ratio - typedef std::vector< graph_traits< grap_real_t >::edge_descriptor > - ccReal_t; + using ccReal_t + = std::vector< graph_traits< grap_real_t >::edge_descriptor >; ccReal_t cc; /// critical cycle grap_real_t tgr; diff --git a/example/dag_shortest_paths.cpp b/example/dag_shortest_paths.cpp index 016c4ac62..fe459ab7d 100644 --- a/example/dag_shortest_paths.cpp +++ b/example/dag_shortest_paths.cpp @@ -25,9 +25,8 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, - property< vertex_distance_t, int >, property< edge_weight_t, int > > - graph_t; + using graph_t = adjacency_list< vecS, vecS, directedS, + property< vertex_distance_t, int >, property< edge_weight_t, int > >; graph_t g(6); enum verts { diff --git a/example/dave.cpp b/example/dave.cpp index 74e9322cd..dec8b2533 100644 --- a/example/dave.cpp +++ b/example/dave.cpp @@ -71,18 +71,17 @@ b(14); d a */ -typedef property< vertex_color_t, default_color_type, - property< vertex_distance_t, int > > - VProperty; -typedef int weight_t; -typedef property< edge_weight_t, weight_t > EProperty; +using VProperty = property< vertex_color_t, default_color_type, + property< vertex_distance_t, int > >; +using weight_t = int; +using EProperty = property< edge_weight_t, weight_t >; -typedef adjacency_list< vecS, vecS, directedS, VProperty, EProperty > Graph; +using Graph = adjacency_list< vecS, vecS, directedS, VProperty, EProperty >; template < class Tag > struct endl_printer : public boost::base_visitor< endl_printer< Tag > > { - typedef Tag event_filter; + using event_filter = Tag; endl_printer(std::ostream& os) : m_os(os) {} template < class T, class Graph > void operator()(T, Graph&) { @@ -98,7 +97,7 @@ template < class Tag > endl_printer< Tag > print_endl(std::ostream& os, Tag) template < class PA, class Tag > struct edge_printer : public boost::base_visitor< edge_printer< PA, Tag > > { - typedef Tag event_filter; + using event_filter = Tag; edge_printer(PA pa, std::ostream& os) : m_pa(pa), m_os(os) {} @@ -120,7 +119,7 @@ template < class NewGraph, class Tag > struct graph_copier : public boost::base_visitor< graph_copier< NewGraph, Tag > > { - typedef Tag event_filter; + using event_filter = Tag; graph_copier(NewGraph& graph) : new_g(graph) {} @@ -172,10 +171,10 @@ int main(int, char*[]) auto vertex_id = get(vertex_index, G); std::vector< weight_t > distance(N, (numeric_limits< weight_t >::max)()); - typedef boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = boost::graph_traits< Graph >::vertex_descriptor; std::vector< Vertex > parent(N); - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; diff --git a/example/default-constructor.cpp b/example/default-constructor.cpp index 71d9b3ef7..0172538de 100644 --- a/example/default-constructor.cpp +++ b/example/default-constructor.cpp @@ -13,7 +13,7 @@ using namespace boost; template < typename Graph > void read_graph_file(std::istream& in, Graph& g) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices for (size_type i = 0; i < n_vertices; ++i) // Add n vertices to the graph @@ -28,12 +28,11 @@ template < typename Graph > void read_graph_file(std::istream& in, Graph& g) int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > - graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); diff --git a/example/default-constructor2.cpp b/example/default-constructor2.cpp index 18f886057..e6f4983c0 100644 --- a/example/default-constructor2.cpp +++ b/example/default-constructor2.cpp @@ -13,8 +13,8 @@ using namespace boost; template < typename Graph > void read_graph_file(std::istream& in, Graph& g) { - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; in >> n_vertices; // read in number of vertices std::vector< Vertex > vertex_set(n_vertices); @@ -31,12 +31,11 @@ template < typename Graph > void read_graph_file(std::istream& in, Graph& g) int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > - graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); diff --git a/example/degree_centrality.cpp b/example/degree_centrality.cpp index 1dbee79b4..cd249bfac 100644 --- a/example/degree_centrality.cpp +++ b/example/degree_centrality.cpp @@ -24,19 +24,19 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a container type for degree centralities and its // corresponding property map. -typedef exterior_vertex_property< Graph, unsigned > CentralityProperty; -typedef CentralityProperty::container_type CentralityContainer; -typedef CentralityProperty::map_type CentralityMap; +using CentralityProperty = exterior_vertex_property< Graph, unsigned >; +using CentralityContainer = CentralityProperty::container_type; +using CentralityMap = CentralityProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/dfs-example.cpp b/example/dfs-example.cpp index fff17bfdd..a508f5565 100644 --- a/example/dfs-example.cpp +++ b/example/dfs-example.cpp @@ -16,7 +16,7 @@ using namespace boost; template < typename TimeMap > class dfs_time_visitor : public default_dfs_visitor { - typedef typename property_traits< TimeMap >::value_type T; + using T = typename property_traits< TimeMap >::value_type; public: dfs_time_visitor(TimeMap dmap, TimeMap fmap, T& t) @@ -41,8 +41,8 @@ class dfs_time_visitor : public default_dfs_visitor int main() { // Select the graph type we wish to use - typedef adjacency_list< vecS, vecS, directedS > graph_t; - typedef graph_traits< graph_t >::vertices_size_type size_type; + using graph_t = adjacency_list< vecS, vecS, directedS >; + using size_type = graph_traits< graph_t >::vertices_size_type; // Set up the vertex names enum { @@ -56,7 +56,7 @@ int main() }; char name[] = { 'u', 'v', 'w', 'x', 'y', 'z' }; // Specify the edges in the graph - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edge_array[] = { E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y), E(w, z), E(z, z) }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -70,9 +70,9 @@ int main() // discover time and finish time properties std::vector< size_type > dtime(num_vertices(g)); std::vector< size_type > ftime(num_vertices(g)); - typedef iterator_property_map< std::vector< size_type >::iterator, - property_map< graph_t, vertex_index_t >::const_type > - time_pm_type; + using time_pm_type + = iterator_property_map< std::vector< size_type >::iterator, + property_map< graph_t, vertex_index_t >::const_type >; time_pm_type dtime_pm(dtime.begin(), get(vertex_index, g)); time_pm_type ftime_pm(ftime.begin(), get(vertex_index, g)); size_type t = 0; diff --git a/example/dfs.cpp b/example/dfs.cpp index b052a214f..3594894f2 100644 --- a/example/dfs.cpp +++ b/example/dfs.cpp @@ -52,7 +52,7 @@ using namespace std; template < class VisitorList > struct edge_categorizer : public dfs_visitor< VisitorList > { - typedef dfs_visitor< VisitorList > Base; + using Base = dfs_visitor< VisitorList >; edge_categorizer(const VisitorList& v = null_visitor()) : Base(v) {} @@ -93,7 +93,7 @@ int main(int, char*[]) using namespace boost; - typedef adjacency_list<> Graph; + using Graph = adjacency_list<>; Graph G(5); add_edge(0, 2, G); @@ -106,7 +106,7 @@ int main(int, char*[]) add_edge(4, 0, G); add_edge(4, 1, G); - typedef graph_traits< Graph >::vertices_size_type size_type; + using size_type = graph_traits< Graph >::vertices_size_type; std::vector< size_type > d(num_vertices(G)); std::vector< size_type > f(num_vertices(G)); diff --git a/example/dfs_parenthesis.cpp b/example/dfs_parenthesis.cpp index 6a4214451..245392984 100644 --- a/example/dfs_parenthesis.cpp +++ b/example/dfs_parenthesis.cpp @@ -29,7 +29,7 @@ using namespace std; struct open_paren : public base_visitor< open_paren > { - typedef on_discover_vertex event_filter; + using event_filter = on_discover_vertex; template < class Vertex, class Graph > void operator()(Vertex v, Graph&) { std::cout << "(" << v; @@ -37,7 +37,7 @@ struct open_paren : public base_visitor< open_paren > }; struct close_paren : public base_visitor< close_paren > { - typedef on_finish_vertex event_filter; + using event_filter = on_finish_vertex; template < class Vertex, class Graph > void operator()(Vertex v, Graph&) { std::cout << v << ")"; @@ -49,8 +49,8 @@ int main(int, char*[]) using namespace boost; - typedef adjacency_list<> Graph; - typedef std::pair< int, int > E; + using Graph = adjacency_list<>; + using E = std::pair< int, int >; E edge_array[] = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1), E(3, 4), E(4, 0), E(4, 1) }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 diff --git a/example/dijkstra-example-listS.cpp b/example/dijkstra-example-listS.cpp index 4e9757095..fefd62999 100644 --- a/example/dijkstra-example-listS.cpp +++ b/example/dijkstra-example-listS.cpp @@ -17,16 +17,15 @@ using namespace boost; int main(int, char*[]) { - typedef adjacency_list_traits< listS, listS, directedS >::vertex_descriptor - vertex_descriptor; - typedef adjacency_list< listS, listS, directedS, + using vertex_descriptor + = adjacency_list_traits< listS, listS, directedS >::vertex_descriptor; + using graph_t = adjacency_list< listS, listS, directedS, property< vertex_index_t, int, property< vertex_name_t, char, property< vertex_distance_t, int, property< vertex_predecessor_t, vertex_descriptor > > > >, - property< edge_weight_t, int > > - graph_t; - typedef std::pair< int, int > Edge; + property< edge_weight_t, int > >; + using Edge = std::pair< int, int >; const int num_nodes = 5; enum nodes diff --git a/example/dijkstra-example.cpp b/example/dijkstra-example.cpp index 1092ece84..e4517669f 100644 --- a/example/dijkstra-example.cpp +++ b/example/dijkstra-example.cpp @@ -18,11 +18,10 @@ using namespace boost; int main(int, char*[]) { - typedef adjacency_list< listS, vecS, directedS, no_property, - property< edge_weight_t, int > > - graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_descriptor; - typedef std::pair< int, int > Edge; + using graph_t = adjacency_list< listS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using vertex_descriptor = graph_traits< graph_t >::vertex_descriptor; + using Edge = std::pair< int, int >; const int num_nodes = 5; enum nodes diff --git a/example/dijkstra-no-color-map-example.cpp b/example/dijkstra-no-color-map-example.cpp index 3d737b1a3..97b01c81f 100644 --- a/example/dijkstra-no-color-map-example.cpp +++ b/example/dijkstra-no-color-map-example.cpp @@ -22,11 +22,10 @@ using namespace boost; int main(int, char*[]) { - typedef adjacency_list< listS, vecS, directedS, no_property, - property< edge_weight_t, int > > - graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_descriptor; - typedef std::pair< int, int > Edge; + using graph_t = adjacency_list< listS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using vertex_descriptor = graph_traits< graph_t >::vertex_descriptor; + using Edge = std::pair< int, int >; const int num_nodes = 5; enum nodes diff --git a/example/directed_graph.cpp b/example/directed_graph.cpp index 41fe874ec..90809d5bc 100644 --- a/example/directed_graph.cpp +++ b/example/directed_graph.cpp @@ -16,7 +16,7 @@ int main(int, char*[]) // the code easier to understand. However, it hard codes many of the // template parameters, so it is much less flexible. - typedef boost::directed_graph<> Graph; + using Graph = boost::directed_graph<>; Graph g; auto v0 = g.add_vertex(); auto v1 = g.add_vertex(); diff --git a/example/eccentricity.cpp b/example/eccentricity.cpp index 58e43ace1..8577ca2c9 100644 --- a/example/eccentricity.cpp +++ b/example/eccentricity.cpp @@ -24,29 +24,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property< Graph, int > DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property< Graph, int >; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map< Edge, int > WeightMap; +using WeightMap = constant_property_map< Edge, int >; // Declare a container and its corresponding property map that // will contain the resulting eccentricities of each vertex in // the graph. -typedef boost::exterior_vertex_property< Graph, int > EccentricityProperty; -typedef EccentricityProperty::container_type EccentricityContainer; -typedef EccentricityProperty::map_type EccentricityMap; +using EccentricityProperty = boost::exterior_vertex_property< Graph, int >; +using EccentricityContainer = EccentricityProperty::container_type; +using EccentricityMap = EccentricityProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/edge-connectivity.cpp b/example/edge-connectivity.cpp index 5f93d54ea..a9bb1a330 100644 --- a/example/edge-connectivity.cpp +++ b/example/edge-connectivity.cpp @@ -29,7 +29,7 @@ std::pair< typename graph_traits< Graph >::vertex_descriptor, min_degree_vertex(Graph& g) { typename graph_traits< Graph >::vertex_descriptor p; - typedef typename graph_traits< Graph >::degree_size_type size_type; + using size_type = typename graph_traits< Graph >::degree_size_type; auto delta = (std::numeric_limits< size_type >::max)(); typename graph_traits< Graph >::vertex_iterator i, iend; for (boost::tie(i, iend) = vertices(g); i != iend; ++i) @@ -61,19 +61,17 @@ template < typename VertexListGraph, typename OutputIterator > typename graph_traits< VertexListGraph >::degree_size_type edge_connectivity( VertexListGraph& g, OutputIterator disconnecting_set) { - typedef typename graph_traits< VertexListGraph >::vertex_descriptor - vertex_descriptor; - typedef typename graph_traits< VertexListGraph >::degree_size_type - degree_size_type; - typedef color_traits< default_color_type > Color; - typedef - typename adjacency_list_traits< vecS, vecS, directedS >::edge_descriptor - edge_descriptor; - typedef adjacency_list< vecS, vecS, directedS, no_property, + using vertex_descriptor = + typename graph_traits< VertexListGraph >::vertex_descriptor; + using degree_size_type = + typename graph_traits< VertexListGraph >::degree_size_type; + using Color = color_traits< default_color_type >; + using edge_descriptor = typename adjacency_list_traits< vecS, vecS, + directedS >::edge_descriptor; + using FlowGraph = adjacency_list< vecS, vecS, directedS, no_property, property< edge_capacity_t, degree_size_type, property< edge_residual_capacity_t, degree_size_type, - property< edge_reverse_t, edge_descriptor > > > > - FlowGraph; + property< edge_reverse_t, edge_descriptor > > > >; vertex_descriptor u, v, p, k; edge_descriptor e1, e2; @@ -136,13 +134,13 @@ typename graph_traits< VertexListGraph >::degree_size_type edge_connectivity( } std::vector< bool > in_S_star(num_vertices(g), false); - for (auto si = S_star.begin(); si != S_star.end(); ++si) - in_S_star[*si] = true; + for (auto const& vertex : S_star.begin()) + in_S_star[vertex] = true; degree_size_type c = 0; - for (auto si = S_star.begin(); si != S_star.end(); ++si) + for (auto const& vertex : S_star.begin()) { typename graph_traits< VertexListGraph >::out_edge_iterator ei, ei_end; - for (boost::tie(ei, ei_end) = out_edges(*si, g); ei != ei_end; ++ei) + for (boost::tie(ei, ei_end) = out_edges(vertex, g); ei != ei_end; ++ei) if (!in_S_star[target(*ei, g)]) { *disconnecting_set++ = *ei; @@ -161,7 +159,7 @@ int main() GraphvizGraph g; read_graphviz("figs/edge-connectivity.dot", g); - typedef graph_traits< GraphvizGraph >::edge_descriptor edge_descriptor; + using edge_descriptor = graph_traits< GraphvizGraph >::edge_descriptor; std::vector< edge_descriptor > disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); @@ -170,9 +168,9 @@ int main() auto attr_map = get(vertex_attribute, g); std::cout << "The disconnecting set is {"; - for (auto i = disconnecting_set.begin(); i != disconnecting_set.end(); ++i) - std::cout << "(" << attr_map[source(*i, g)]["label"] << "," - << attr_map[target(*i, g)]["label"] << ") "; + for (auto const& edge : disconnecting_set) + std::cout << "(" << attr_map[source(edge, g)]["label"] << "," + << attr_map[target(edge, g)]["label"] << ") "; std::cout << "}." << std::endl; return EXIT_SUCCESS; } diff --git a/example/edge-function.cpp b/example/edge-function.cpp index 2db1b7d08..31d2dd7c4 100644 --- a/example/edge-function.cpp +++ b/example/edge-function.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -76,13 +76,12 @@ inline name_equals_t< NameMap > name_equals( int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name diff --git a/example/edge-iter-constructor.cpp b/example/edge-iter-constructor.cpp index 84eb6c2df..c8abe2e9c 100644 --- a/example/edge-iter-constructor.cpp +++ b/example/edge-iter-constructor.cpp @@ -21,15 +21,14 @@ std::istream& operator>>(std::istream& in, std::pair< T, T >& p) int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS // The graph is directed - > - graph_type; + >; std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< graph_type >::vertices_size_type size_type; + using size_type = graph_traits< graph_type >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices diff --git a/example/edge_basics.cpp b/example/edge_basics.cpp index fac231971..3b88d8526 100644 --- a/example/edge_basics.cpp +++ b/example/edge_basics.cpp @@ -40,8 +40,8 @@ template < class Graph > struct exercise_edge { exercise_edge(Graph& g) : G(g) {} - typedef typename boost::graph_traits< Graph >::edge_descriptor Edge; - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Edge = typename boost::graph_traits< Graph >::edge_descriptor; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; void operator()(Edge e) const { // begin @@ -62,9 +62,9 @@ template < class Graph > struct exercise_edge int main() { - typedef adjacency_list<> MyGraph; + using MyGraph = adjacency_list<>; - typedef pair< int, int > Pair; + using Pair = pair< int, int >; Pair edge_array[8] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4), Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1) }; diff --git a/example/edge_coloring.cpp b/example/edge_coloring.cpp index 402337df9..41a796480 100644 --- a/example/edge_coloring.cpp +++ b/example/edge_coloring.cpp @@ -36,11 +36,10 @@ int main(int, char*[]) { using namespace boost; using namespace std; - typedef adjacency_list< vecS, vecS, undirectedS, no_property, size_t, - no_property > - Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS, no_property, size_t, + no_property >; - typedef std::pair< std::size_t, std::size_t > Pair; + using Pair = std::pair< std::size_t, std::size_t >; Pair edges[14] = { Pair(0, 3), // a-d Pair(0, 5), // a-f Pair(1, 2), // b-c diff --git a/example/edge_connectivity.cpp b/example/edge_connectivity.cpp index e273a3d3f..cf30a3613 100644 --- a/example/edge_connectivity.cpp +++ b/example/edge_connectivity.cpp @@ -27,7 +27,7 @@ using namespace boost; int main() { const int N = 8; - typedef adjacency_list< vecS, vecS, undirectedS > UndirectedGraph; + using UndirectedGraph = adjacency_list< vecS, vecS, undirectedS >; UndirectedGraph g(N); add_edge(0, 1, g); @@ -45,8 +45,8 @@ int main() add_edge(5, 7, g); add_edge(6, 7, g); - typedef graph_traits< UndirectedGraph >::edge_descriptor edge_descriptor; - typedef graph_traits< UndirectedGraph >::degree_size_type degree_size_type; + using edge_descriptor = graph_traits< UndirectedGraph >::edge_descriptor; + using degree_size_type = graph_traits< UndirectedGraph >::degree_size_type; std::vector< edge_descriptor > disconnecting_set; auto c = edge_connectivity(g, std::back_inserter(disconnecting_set)); diff --git a/example/edge_iterator_constructor.cpp b/example/edge_iterator_constructor.cpp index 6c2c6f724..96f0d4d94 100644 --- a/example/edge_iterator_constructor.cpp +++ b/example/edge_iterator_constructor.cpp @@ -44,11 +44,11 @@ class edge_stream_iterator { public: - typedef std::input_iterator_tag iterator_category; - typedef std::pair< int, int > value_type; - typedef std::ptrdiff_t difference_type; - typedef const value_type* pointer; - typedef const value_type& reference; + using iterator_category = std::input_iterator_tag; + using value_type = std::pair< int, int >; + using difference_type = std::ptrdiff_t; + using pointer = const value_type*; + using reference = const value_type&; edge_stream_iterator() : m_stream(0), m_end_marker(false) {} edge_stream_iterator(std::istream& s) : m_stream(&s) { m_read(); } @@ -93,8 +93,8 @@ bool operator!=(const edge_stream_iterator& x, const edge_stream_iterator& y) int main(int argc, const char** argv) { - typedef boost::adjacency_list<> IteratorConstructibleGraph; - typedef boost::graph_traits< IteratorConstructibleGraph > Traits; + using IteratorConstructibleGraph = boost::adjacency_list<>; + using Traits = boost::graph_traits< IteratorConstructibleGraph >; Traits::vertices_size_type size_V; Traits::edges_size_type size_E; diff --git a/example/edge_property.cpp b/example/edge_property.cpp index 9fe2272d2..6941e8257 100644 --- a/example/edge_property.cpp +++ b/example/edge_property.cpp @@ -75,10 +75,10 @@ BOOST_INSTALL_PROPERTY(edge, mycapacity); template < class Graph > void print_network(const Graph& G) { - typedef typename boost::graph_traits< Graph >::vertex_iterator Viter; - typedef - typename boost::graph_traits< Graph >::out_edge_iterator OutEdgeIter; - typedef typename boost::graph_traits< Graph >::in_edge_iterator InEdgeIter; + using Viter = typename boost::graph_traits< Graph >::vertex_iterator; + using OutEdgeIter = + typename boost::graph_traits< Graph >::out_edge_iterator; + using InEdgeIter = typename boost::graph_traits< Graph >::in_edge_iterator; auto capacity = get(edge_mycapacity, G); auto flow = get(edge_myflow, G); @@ -109,10 +109,10 @@ template < class Graph > void print_network(const Graph& G) int main(int, char*[]) { - typedef property< edge_mycapacity_t, int > Cap; - typedef property< edge_myflow_t, int, Cap > Flow; - typedef adjacency_list< vecS, vecS, bidirectionalS, no_property, Flow > - Graph; + using Cap = property< edge_mycapacity_t, int >; + using Flow = property< edge_myflow_t, int, Cap >; + using Graph + = adjacency_list< vecS, vecS, bidirectionalS, no_property, Flow >; const int num_vertices = 9; Graph G(num_vertices); diff --git a/example/edmonds-karp-eg.cpp b/example/edmonds-karp-eg.cpp index a07bde38b..e61c5292a 100644 --- a/example/edmonds-karp-eg.cpp +++ b/example/edmonds-karp-eg.cpp @@ -51,13 +51,12 @@ int main() { using namespace boost; - typedef adjacency_list_traits< vecS, vecS, directedS > Traits; - typedef adjacency_list< listS, vecS, directedS, + using Traits = adjacency_list_traits< vecS, vecS, directedS >; + using Graph = adjacency_list< listS, vecS, directedS, property< vertex_name_t, std::string >, property< edge_capacity_t, long, property< edge_residual_capacity_t, long, - property< edge_reverse_t, Traits::edge_descriptor > > > > - Graph; + property< edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; diff --git a/example/exterior_properties.cpp b/example/exterior_properties.cpp index 4c2e892f7..7d0a99b6b 100644 --- a/example/exterior_properties.cpp +++ b/example/exterior_properties.cpp @@ -40,10 +40,10 @@ template < class Graph, class Capacity, class Flow > void print_network(Graph& G, Capacity capacity, Flow flow) { - typedef typename boost::graph_traits< Graph >::vertex_iterator Viter; - typedef - typename boost::graph_traits< Graph >::out_edge_iterator OutEdgeIter; - typedef typename boost::graph_traits< Graph >::in_edge_iterator InEdgeIter; + using Viter = typename boost::graph_traits< Graph >::vertex_iterator; + using OutEdgeIter = + typename boost::graph_traits< Graph >::out_edge_iterator; + using InEdgeIter = typename boost::graph_traits< Graph >::in_edge_iterator; Viter ui, uiend; for (boost::tie(ui, uiend) = boost::vertices(G); ui != uiend; ++ui) @@ -71,10 +71,9 @@ void print_network(Graph& G, Capacity capacity, Flow flow) int main(int, char*[]) { - typedef boost::adjacency_list< boost::vecS, boost::vecS, + using Graph = boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, boost::no_property, - boost::property< boost::edge_index_t, std::size_t > > - Graph; + boost::property< boost::edge_index_t, std::size_t > >; const int num_vertices = 9; Graph G(num_vertices); @@ -110,12 +109,12 @@ int main(int, char*[]) boost::add_edge(6, 8, 9, G); - typedef boost::property_map< Graph, boost::edge_index_t >::type - EdgeIndexMap; + using EdgeIndexMap + = boost::property_map< Graph, boost::edge_index_t >::type; EdgeIndexMap edge_id = boost::get(boost::edge_index, G); - typedef boost::iterator_property_map< int*, EdgeIndexMap, int, int& > - IterMap; + using IterMap + = boost::iterator_property_map< int*, EdgeIndexMap, int, int& >; print_network(G, IterMap(capacity, edge_id), IterMap(flow, edge_id)); diff --git a/example/exterior_property_map.cpp b/example/exterior_property_map.cpp index 8aa404757..92945148c 100644 --- a/example/exterior_property_map.cpp +++ b/example/exterior_property_map.cpp @@ -76,9 +76,9 @@ int main(int, char*[]) names[3] = "Jeff"; names[4] = "Kinis"; - typedef adjacency_list<> MyGraphType; + using MyGraphType = adjacency_list<>; - typedef pair< int, int > Pair; + using Pair = pair< int, int >; Pair edge_array[11] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4), Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1), Pair(3, 4), Pair(4, 0), Pair(4, 1) }; diff --git a/example/fibonacci_heap.cpp b/example/fibonacci_heap.cpp index ca70367dd..b602c1ad8 100644 --- a/example/fibonacci_heap.cpp +++ b/example/fibonacci_heap.cpp @@ -26,7 +26,7 @@ using namespace boost; int main() { - typedef indirect_cmp< float*, std::less< float > > ICmp; + using ICmp = indirect_cmp< float*, std::less< float > >; int i; random_ns::mt19937 gen; for (int N = 2; N < 200; ++N) diff --git a/example/file_dependencies.cpp b/example/file_dependencies.cpp index d4344b98f..e8f88248e 100644 --- a/example/file_dependencies.cpp +++ b/example/file_dependencies.cpp @@ -92,7 +92,7 @@ struct cycle_detector : public dfs_visitor<> int main(int, char*[]) { - typedef pair< int, int > Edge; + using Edge = pair< int, int >; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp), @@ -103,7 +103,7 @@ int main(int, char*[]) Edge(zag_o, libzigzag_a), Edge(libzigzag_a, killerapp) }; const std::size_t nedges = sizeof(used_by) / sizeof(Edge); - typedef adjacency_list< vecS, vecS, bidirectionalS > Graph; + using Graph = adjacency_list< vecS, vecS, bidirectionalS >; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor Graph g(N); @@ -117,12 +117,12 @@ int main(int, char*[]) #else Graph g(used_by, used_by + nedges, N); #endif - typedef graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = graph_traits< Graph >::vertex_descriptor; // Determine ordering for a full recompilation // and the order with files that can be compiled in parallel { - typedef list< Vertex > MakeOrder; + using MakeOrder = list< Vertex >; MakeOrder::iterator i; MakeOrder make_order; diff --git a/example/filtered-copy-example.cpp b/example/filtered-copy-example.cpp index 19490c55e..e5cc472d1 100644 --- a/example/filtered-copy-example.cpp +++ b/example/filtered-copy-example.cpp @@ -29,9 +29,8 @@ template < typename Graph > struct non_zero_degree int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, bidirectionalS, - property< vertex_name_t, char > > - graph_t; + using graph_t = adjacency_list< vecS, vecS, bidirectionalS, + property< vertex_name_t, char > >; enum { @@ -51,7 +50,7 @@ int main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edges[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; for (int i = 0; i < 12; ++i) diff --git a/example/filtered_graph.cpp b/example/filtered_graph.cpp index 9a89718c9..88a52076e 100644 --- a/example/filtered_graph.cpp +++ b/example/filtered_graph.cpp @@ -40,10 +40,9 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, no_property, - property< edge_weight_t, int > > - Graph; - typedef property_map< Graph, edge_weight_t >::type EdgeWeightMap; + using Graph = adjacency_list< vecS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using EdgeWeightMap = property_map< Graph, edge_weight_t >::type; enum { diff --git a/example/filtered_graph_edge_range.cpp b/example/filtered_graph_edge_range.cpp index 775980821..8d289b027 100644 --- a/example/filtered_graph_edge_range.cpp +++ b/example/filtered_graph_edge_range.cpp @@ -40,10 +40,9 @@ int main() { using namespace boost; - typedef adjacency_list< multisetS, vecS, directedS, no_property, - property< edge_weight_t, int > > - Graph; - typedef property_map< Graph, edge_weight_t >::type EdgeWeightMap; + using Graph = adjacency_list< multisetS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using EdgeWeightMap = property_map< Graph, edge_weight_t >::type; enum { @@ -74,8 +73,8 @@ int main() << name[target(*f, g)] << "\n"; positive_edge_weight< EdgeWeightMap > filter(weight); - typedef filtered_graph< Graph, positive_edge_weight< EdgeWeightMap > > - FGraph; + using FGraph + = filtered_graph< Graph, positive_edge_weight< EdgeWeightMap > >; FGraph fg(g, filter); std::cout << "filtered edge_range(C,D)\n"; diff --git a/example/filtered_vec_as_graph.cpp b/example/filtered_vec_as_graph.cpp index 2ec53a226..d749f4112 100644 --- a/example/filtered_vec_as_graph.cpp +++ b/example/filtered_vec_as_graph.cpp @@ -45,18 +45,15 @@ int main() B, C, D, - E, - N + E }; const char* name = "ABCDE"; - typedef std::vector< std::list< int > > Graph; - Graph g(N); - g[A].push_back(B); - g[A].push_back(C); - g[C].push_back(D); - g[C].push_back(E); - g[D].push_back(E); - g[E].push_back(C); + using Graph = std::vector< std::list< int > >; + Graph g = { { B, C }, // A + {}, // B + { D, E }, // C + { E }, // D + { C } }; // E constant_target filter(E); filtered_graph< Graph, constant_target > fg(g, filter); diff --git a/example/fr_layout.cpp b/example/fr_layout.cpp index ea49708e4..96a783d7e 100644 --- a/example/fr_layout.cpp +++ b/example/fr_layout.cpp @@ -41,16 +41,15 @@ void usage() "vertex on each line, separated by spaces.\n"; } -typedef boost::rectangle_topology<> topology_type; -typedef topology_type::point_type point_type; +using topology_type = boost::rectangle_topology<>; +using point_type = topology_type::point_type; -typedef adjacency_list< listS, vecS, undirectedS, - property< vertex_name_t, std::string > > - Graph; +using Graph = adjacency_list< listS, vecS, undirectedS, + property< vertex_name_t, std::string > >; -typedef graph_traits< Graph >::vertex_descriptor Vertex; +using Vertex = graph_traits< Graph >::vertex_descriptor; -typedef std::map< std::string, Vertex > NameToVertex; +using NameToVertex = std::map< std::string, Vertex >; Vertex get_vertex(const std::string& name, Graph& g, NameToVertex& names) { @@ -62,7 +61,7 @@ Vertex get_vertex(const std::string& name, Graph& g, NameToVertex& names) class progress_cooling : public linear_cooling< double > { - typedef linear_cooling< double > inherited; + using inherited = linear_cooling< double >; public: explicit progress_cooling(std::size_t iterations) : inherited(iterations) @@ -135,11 +134,10 @@ int main(int argc, char* argv[]) add_edge(get_vertex(source, g, names), get_vertex(target, g, names), g); } - typedef std::vector< point_type > PositionVec; + using PositionVec = std::vector< point_type >; PositionVec position_vec(num_vertices(g)); - typedef iterator_property_map< PositionVec::iterator, - property_map< Graph, vertex_index_t >::type > - PositionMap; + using PositionMap = iterator_property_map< PositionVec::iterator, + property_map< Graph, vertex_index_t >::type >; PositionMap position(position_vec.begin(), get(vertex_index, g)); minstd_rand gen; diff --git a/example/gerdemann.cpp b/example/gerdemann.cpp index 9058435c3..9f815d0ff 100644 --- a/example/gerdemann.cpp +++ b/example/gerdemann.cpp @@ -42,7 +42,7 @@ void merge_vertex(typename boost::graph_traits< Graph >::vertex_descriptor u, typename boost::graph_traits< Graph >::vertex_descriptor v, Graph& g, GetEdgeProperties getp) { - typedef boost::graph_traits< Graph > Traits; + using Traits = boost::graph_traits< Graph >; typename Traits::edge_descriptor e; typename Traits::out_edge_iterator out_i, out_end; for (boost::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; @@ -65,9 +65,9 @@ void merge_vertex(typename boost::graph_traits< Graph >::vertex_descriptor u, template < class StoredEdge > struct order_by_name { - typedef StoredEdge first_argument_type; - typedef StoredEdge second_argument_type; - typedef bool result_type; + using first_argument_type = StoredEdge; + using second_argument_type = StoredEdge; + using result_type = bool; bool operator()(const StoredEdge& e1, const StoredEdge& e2) const { // Using std::pair operator< as an easy way to get lexicographical @@ -86,11 +86,11 @@ namespace boost template < class ValueType > struct container_gen< ordered_set_by_nameS, ValueType > { - typedef std::set< ValueType, order_by_name< ValueType > > type; + using type = std::set< ValueType, order_by_name< ValueType > >; }; template <> struct parallel_edge_traits< ordered_set_by_nameS > { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; } #endif @@ -114,10 +114,9 @@ int main() std::cout << "This program requires partial specialization." << std::endl; #else using namespace boost; - typedef property< edge_name_t, char > EdgeProperty; - typedef adjacency_list< ordered_set_by_nameS, vecS, bidirectionalS, - no_property, EdgeProperty > - graph_type; + using EdgeProperty = property< edge_name_t, char >; + using graph_type = adjacency_list< ordered_set_by_nameS, vecS, + bidirectionalS, no_property, EdgeProperty >; graph_type g; diff --git a/example/girth.cpp b/example/girth.cpp index a55aae2a0..0a031e1e9 100644 --- a/example/girth.cpp +++ b/example/girth.cpp @@ -49,20 +49,20 @@ #include #include -typedef boost::graph_traits< Graph* > Traits; -typedef Traits::vertex_descriptor vertex_descriptor; -typedef Traits::edge_descriptor edge_descriptor; -typedef Traits::vertex_iterator vertex_iterator; +using Traits = boost::graph_traits< Graph* >; +using vertex_descriptor = Traits::vertex_descriptor; +using edge_descriptor = Traits::edge_descriptor; +using vertex_iterator = Traits::vertex_iterator; std::vector< std::size_t > distance_list; -typedef boost::v_property< long > dist_t; +using dist_t = boost::v_property< long >; boost::property_map< Graph*, dist_t >::type d_map; -typedef boost::u_property< vertex_descriptor > pred_t; +using pred_t = boost::u_property< vertex_descriptor >; boost::property_map< Graph*, pred_t >::type p_map; -typedef boost::w_property< long > color_t; +using color_t = boost::w_property< long >; boost::property_map< Graph*, color_t >::type c_map; class diameter_and_girth_visitor : public boost::bfs_visitor<> diff --git a/example/graph-assoc-types.cpp b/example/graph-assoc-types.cpp index 5af9a8cc4..03cb87910 100644 --- a/example/graph-assoc-types.cpp +++ b/example/graph-assoc-types.cpp @@ -13,11 +13,11 @@ using namespace boost; template < typename Graph > void generic_foo(Graph& g) { // Access descriptor types - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename graph_traits< Graph >::edge_descriptor Edge; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using Edge = typename graph_traits< Graph >::edge_descriptor; // Access category types - typedef typename graph_traits< Graph >::directed_category Dir; - typedef typename graph_traits< Graph >::edge_parallel_category Par; + using Dir = typename graph_traits< Graph >::directed_category; + using Par = typename graph_traits< Graph >::edge_parallel_category; // Access iterator types... // Access size types... // Now do something useful... @@ -52,7 +52,7 @@ template < typename Graph > void foo_dispatch(Graph& g, boost::undirected_tag) template < typename Graph > void foo(Graph& g) { - typedef typename boost::graph_traits< Graph >::directed_category Cat; + using Cat = typename boost::graph_traits< Graph >::directed_category; foo_dispatch(g, Cat()); } @@ -61,7 +61,7 @@ void foo(Digraph& digraph, typename graph_traits< Digraph >::vertex_descriptor u, typename graph_traits< Digraph >::vertex_descriptor v) { - typedef typename graph_traits< Digraph >::edge_descriptor edge_t; + using edge_t = typename graph_traits< Digraph >::edge_descriptor; std::pair< edge_t, bool > e1, e2; e1 = edge(u, v, digraph); e2 = edge(v, u, digraph); @@ -72,7 +72,7 @@ void bar(Undigraph& undigraph, typename graph_traits< Undigraph >::vertex_descriptor u, typename graph_traits< Undigraph >::vertex_descriptor v) { - typedef typename graph_traits< Undigraph >::edge_descriptor edge_t; + using edge_t = typename graph_traits< Undigraph >::edge_descriptor; std::pair< edge_t, bool > e1, e2; e1 = edge(u, v, undigraph); e2 = edge(v, u, undigraph); diff --git a/example/graph-property-iter-eg.cpp b/example/graph-property-iter-eg.cpp index 27ac96d45..9b5986ca0 100644 --- a/example/graph-property-iter-eg.cpp +++ b/example/graph-property-iter-eg.cpp @@ -15,9 +15,8 @@ int main() { using namespace boost; - typedef adjacency_list< listS, vecS, directedS, - property< vertex_name_t, std::string > > - graph_t; + using graph_t = adjacency_list< listS, vecS, directedS, + property< vertex_name_t, std::string > >; graph_t g(3); const char* vertex_names[] = { "Kubrick", "Clark", "Hal" }; diff --git a/example/graph-thingie.cpp b/example/graph-thingie.cpp index eaa5dc825..71eaa7809 100644 --- a/example/graph-thingie.cpp +++ b/example/graph-thingie.cpp @@ -24,29 +24,27 @@ using namespace std; // (see the documentation for adjacency list) struct graph_identifier_t { - typedef graph_property_tag kind; + using kind = graph_property_tag; }; struct vertex_label_t { - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; int main() { // Vertex properties - typedef property< vertex_name_t, string, - property< vertex_label_t, string, property< vertex_root_t, int > > > - vertex_p; + using vertex_p = property< vertex_name_t, string, + property< vertex_label_t, string, property< vertex_root_t, int > > >; // Edge properties - typedef property< edge_name_t, string > edge_p; + using edge_p = property< edge_name_t, string >; // Graph properties - typedef property< graph_name_t, string, - property< graph_identifier_t, string > > - graph_p; + using graph_p = property< graph_name_t, string, + property< graph_identifier_t, string > >; // adjacency_list-based type - typedef adjacency_list< vecS, vecS, directedS, vertex_p, edge_p, graph_p > - graph_t; + using graph_t + = adjacency_list< vecS, vecS, directedS, vertex_p, edge_p, graph_p >; // Construct an empty graph and prepare the dynamic_property_maps. graph_t graph(0); diff --git a/example/graph.cpp b/example/graph.cpp index ee2de06c6..83d30ec87 100644 --- a/example/graph.cpp +++ b/example/graph.cpp @@ -17,16 +17,14 @@ using namespace boost; using namespace std; -typedef property< vertex_color_t, default_color_type, +using VertexProperty = property< vertex_color_t, default_color_type, property< vertex_distance_t, int, property< vertex_degree_t, int, property< vertex_in_degree_t, int, - property< vertex_out_degree_t, int > > > > > - VertexProperty; -typedef property< edge_weight_t, int > EdgeProperty; -typedef adjacency_list< vecS, vecS, bidirectionalS, VertexProperty, - EdgeProperty > - Graph; + property< vertex_out_degree_t, int > > > > >; +using EdgeProperty = property< edge_weight_t, int >; +using Graph = adjacency_list< vecS, vecS, bidirectionalS, VertexProperty, + EdgeProperty >; template < class Graph > void print(Graph& g) { diff --git a/example/graph_as_tree.cpp b/example/graph_as_tree.cpp index 4fa08efff..46d770e84 100644 --- a/example/graph_as_tree.cpp +++ b/example/graph_as_tree.cpp @@ -32,10 +32,9 @@ class tree_printer int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, - property< vertex_name_t, std::string > > - graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_t; + using graph_t = adjacency_list< vecS, vecS, directedS, + property< vertex_name_t, std::string > >; + using vertex_t = graph_traits< graph_t >::vertex_descriptor; graph_t g; @@ -49,11 +48,11 @@ int main() name[b] = "B"; name[c] = "C"; - typedef iterator_property_map< std::vector< vertex_t >::iterator, - property_map< graph_t, vertex_index_t >::type > - parent_map_t; + using parent_map_t + = iterator_property_map< std::vector< vertex_t >::iterator, + property_map< graph_t, vertex_index_t >::type >; std::vector< vertex_t > parent(num_vertices(g)); - typedef graph_as_tree< graph_t, parent_map_t > tree_t; + using tree_t = graph_as_tree< graph_t, parent_map_t >; tree_t t( g, a, make_iterator_property_map(parent.begin(), get(vertex_index, g))); diff --git a/example/graph_property.cpp b/example/graph_property.cpp index eec0ed2f1..fcf0160d5 100644 --- a/example/graph_property.cpp +++ b/example/graph_property.cpp @@ -14,16 +14,15 @@ int main() using namespace boost; using std::string; - typedef adjacency_list< vecS, vecS, directedS, no_property, - property< edge_index_t, int >, property< graph_name_t, string > > - graph_t; + using graph_t = adjacency_list< vecS, vecS, directedS, no_property, + property< edge_index_t, int >, property< graph_name_t, string > >; graph_t g; get_property(g, graph_name) = "graph"; std::cout << "name: " << get_property(g, graph_name) << std::endl; - typedef subgraph< graph_t > subgraph_t; + using subgraph_t = subgraph< graph_t >; subgraph_t sg; get_property(sg, graph_name) = "subgraph"; diff --git a/example/graphviz.cpp b/example/graphviz.cpp index 5c6528976..d0ba491f2 100644 --- a/example/graphviz.cpp +++ b/example/graphviz.cpp @@ -14,13 +14,11 @@ using namespace boost; -typedef boost::adjacency_list< vecS, vecS, directedS, - property< vertex_name_t, std::string >, property< edge_weight_t, double > > - Digraph; +using Digraph = boost::adjacency_list< vecS, vecS, directedS, + property< vertex_name_t, std::string >, property< edge_weight_t, double > >; -typedef boost::adjacency_list< vecS, vecS, undirectedS, - property< vertex_name_t, std::string >, property< edge_weight_t, double > > - Graph; +using Graph = boost::adjacency_list< vecS, vecS, undirectedS, + property< vertex_name_t, std::string >, property< edge_weight_t, double > >; void test_graph_read_write(const std::string& filename) { @@ -38,7 +36,7 @@ void test_graph_read_write(const std::string& filename) BOOST_TEST(num_vertices(g) == 4); BOOST_TEST(num_edges(g) == 4); - typedef graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = graph_traits< Graph >::vertex_descriptor; std::map< std::string, Vertex > name_to_vertex; BGL_FORALL_VERTICES(v, g, Graph) diff --git a/example/grid_graph_example.cpp b/example/grid_graph_example.cpp index c49a3b16d..bd3c251b5 100644 --- a/example/grid_graph_example.cpp +++ b/example/grid_graph_example.cpp @@ -14,8 +14,8 @@ #define DIMENSIONS 3 using namespace boost; -typedef grid_graph< DIMENSIONS > Graph; -typedef graph_traits< Graph > Traits; +using Graph = grid_graph< DIMENSIONS >; +using Traits = graph_traits< Graph >; // Define a simple function to print vertices void print_vertex(Traits::vertex_descriptor vertex_to_print) diff --git a/example/grid_graph_properties.cpp b/example/grid_graph_properties.cpp index e09afc954..a41968e5e 100644 --- a/example/grid_graph_properties.cpp +++ b/example/grid_graph_properties.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { // A 2D grid graph - typedef boost::grid_graph< 2 > GraphType; + using GraphType = boost::grid_graph< 2 >; // Create a 5x5 graph const unsigned int dimension = 5; @@ -22,8 +22,8 @@ int main(int argc, char* argv[]) GraphType graph(lengths); // Get the index map of the grid graph - typedef boost::property_map< GraphType, boost::vertex_index_t >::const_type - indexMapType; + using indexMapType + = boost::property_map< GraphType, boost::vertex_index_t >::const_type; indexMapType indexMap(get(boost::vertex_index, graph)); // Create a float for every node in the graph diff --git a/example/hawick_circuits.cpp b/example/hawick_circuits.cpp index 54346e5e6..c79e402b5 100644 --- a/example/hawick_circuits.cpp +++ b/example/hawick_circuits.cpp @@ -47,8 +47,8 @@ template < typename Graph, typename VertexPairIterator > void build_graph(Graph& graph, unsigned int const nvertices, VertexPairIterator first, VertexPairIterator last) { - typedef boost::graph_traits< Graph > Traits; - typedef typename Traits::vertex_descriptor vertex_descriptor; + using Traits = boost::graph_traits< Graph >; + using vertex_descriptor = typename Traits::vertex_descriptor; std::map< unsigned int, vertex_descriptor > vertices; for (unsigned int i = 0; i < nvertices; ++i) diff --git a/example/helper.hpp b/example/helper.hpp index 571fb724e..44b1e4f84 100644 --- a/example/helper.hpp +++ b/example/helper.hpp @@ -18,8 +18,8 @@ template < typename Graph, typename NameMap, typename VertexMap > typename boost::graph_traits< Graph >::vertex_descriptor add_named_vertex( Graph& g, NameMap nm, const std::string& name, VertexMap& vm) { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename VertexMap::iterator Iterator; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; + using Iterator = typename VertexMap::iterator; Vertex v; Iterator iter; @@ -46,7 +46,7 @@ inline std::map< std::string, typename boost::graph_traits< Graph >::vertex_descriptor > read_graph(Graph& g, NameMap nm, InputStream& is) { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; std::map< std::string, Vertex > verts; for (std::string line; std::getline(is, line);) { @@ -68,8 +68,8 @@ inline std::map< std::string, typename boost::graph_traits< Graph >::vertex_descriptor > read_graph(Graph& g, InputStream& is) { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; - typedef boost::null_property_map< Vertex, std::string > NameMap; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; + using NameMap = boost::null_property_map< Vertex, std::string >; return read_graph(g, NameMap(), is); } @@ -79,8 +79,8 @@ inline std::map< std::string, typename boost::graph_traits< Graph >::vertex_descriptor > read_weighted_graph(Graph& g, NameMap nm, WeightMap wm, InputStream& is) { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; - typedef typename boost::graph_traits< Graph >::edge_descriptor Edge; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; + using Edge = typename boost::graph_traits< Graph >::edge_descriptor; std::map< std::string, Vertex > verts; for (std::string line; std::getline(is, line);) { @@ -113,8 +113,8 @@ inline std::map< std::string, typename boost::graph_traits< Graph >::vertex_descriptor > read_weighted_graph(Graph& g, WeightMap wm, InputStream& is) { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; - typedef boost::null_property_map< Vertex, std::string > NameMap; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; + using NameMap = boost::null_property_map< Vertex, std::string >; return read_weighted_graph(g, NameMap(), wm, is); } diff --git a/example/implicit_graph.cpp b/example/implicit_graph.cpp index 7793cb55a..fad2e2492 100644 --- a/example/implicit_graph.cpp +++ b/example/implicit_graph.cpp @@ -92,14 +92,14 @@ namespace boost { template <> struct property_map< ring_graph, edge_weight_t > { - typedef edge_weight_map type; - typedef edge_weight_map const_type; + using type = edge_weight_map; + using const_type = edge_weight_map; }; template <> struct property_map< const ring_graph, edge_weight_t > { - typedef edge_weight_map type; - typedef edge_weight_map const_type; + using type = edge_weight_map; + using const_type = edge_weight_map; }; } @@ -121,35 +121,35 @@ class ring_graph { public: // Graph associated types - typedef std::size_t vertex_descriptor; - typedef boost::undirected_tag directed_category; - typedef boost::disallow_parallel_edge_tag edge_parallel_category; - typedef ring_traversal_catetory traversal_category; + using vertex_descriptor = std::size_t; + using directed_category = boost::undirected_tag; + using edge_parallel_category = boost::disallow_parallel_edge_tag; + using traversal_category = ring_traversal_catetory; // IncidenceGraph associated types - typedef std::pair< vertex_descriptor, vertex_descriptor > edge_descriptor; - typedef ring_incident_edge_iterator out_edge_iterator; - typedef std::size_t degree_size_type; + using edge_descriptor = std::pair< vertex_descriptor, vertex_descriptor >; + using out_edge_iterator = ring_incident_edge_iterator; + using degree_size_type = std::size_t; // BidirectionalGraph associated types // Note that undirected graphs make no distinction between in- and out- // edges. - typedef ring_incident_edge_iterator in_edge_iterator; + using in_edge_iterator = ring_incident_edge_iterator; // AdjacencyGraph associated types - typedef ring_adjacency_iterator adjacency_iterator; + using adjacency_iterator = ring_adjacency_iterator; // VertexListGraph associated types - typedef boost::counting_iterator< vertex_descriptor > vertex_iterator; - typedef std::size_t vertices_size_type; + using vertex_iterator = boost::counting_iterator< vertex_descriptor >; + using vertices_size_type = std::size_t; // EdgeListGraph associated types - typedef ring_edge_iterator edge_iterator; - typedef std::size_t edges_size_type; + using edge_iterator = ring_edge_iterator; + using edges_size_type = std::size_t; // This type is not part of a graph concept, but is used to return the // default vertex index map used by the Dijkstra search algorithm. - typedef vertex_descriptor vertex_property_type; + using vertex_property_type = vertex_descriptor; ring_graph(std::size_t n) : m_n(n) {}; std::size_t n() const { return m_n; } @@ -161,18 +161,18 @@ class ring_graph // Use these graph_traits parameterizations to refer to the associated // graph types. -typedef boost::graph_traits< ring_graph >::vertex_descriptor vertex_descriptor; -typedef boost::graph_traits< ring_graph >::edge_descriptor edge_descriptor; -typedef boost::graph_traits< ring_graph >::out_edge_iterator out_edge_iterator; -typedef boost::graph_traits< ring_graph >::in_edge_iterator in_edge_iterator; -typedef boost::graph_traits< ring_graph >::adjacency_iterator - adjacency_iterator; -typedef boost::graph_traits< ring_graph >::degree_size_type degree_size_type; -typedef boost::graph_traits< ring_graph >::vertex_iterator vertex_iterator; -typedef boost::graph_traits< ring_graph >::vertices_size_type - vertices_size_type; -typedef boost::graph_traits< ring_graph >::edge_iterator edge_iterator; -typedef boost::graph_traits< ring_graph >::edges_size_type edges_size_type; +using vertex_descriptor = boost::graph_traits< ring_graph >::vertex_descriptor; +using edge_descriptor = boost::graph_traits< ring_graph >::edge_descriptor; +using out_edge_iterator = boost::graph_traits< ring_graph >::out_edge_iterator; +using in_edge_iterator = boost::graph_traits< ring_graph >::in_edge_iterator; +using adjacency_iterator + = boost::graph_traits< ring_graph >::adjacency_iterator; +using degree_size_type = boost::graph_traits< ring_graph >::degree_size_type; +using vertex_iterator = boost::graph_traits< ring_graph >::vertex_iterator; +using vertices_size_type + = boost::graph_traits< ring_graph >::vertices_size_type; +using edge_iterator = boost::graph_traits< ring_graph >::edge_iterator; +using edges_size_type = boost::graph_traits< ring_graph >::edges_size_type; // Tag values passed to an iterator constructor to specify whether it should // be created at the start or the end of its range. @@ -295,8 +295,8 @@ class ring_adjacency_iterator { // The parent class is an iterator_adpator that turns an iterator over // out edges into an iterator over adjacent vertices. - typedef boost::adjacency_iterator_generator< ring_graph, vertex_descriptor, - out_edge_iterator >::type parent_class; + using parent_class = boost::adjacency_iterator_generator< ring_graph, + vertex_descriptor, out_edge_iterator >::type; public: ring_adjacency_iterator() {}; @@ -395,10 +395,10 @@ Map from edges to weight values */ struct edge_weight_map { - typedef double value_type; - typedef value_type reference; - typedef edge_descriptor key_type; - typedef boost::readable_property_map_tag category; + using value_type = double; + using reference = value_type; + using key_type = edge_descriptor; + using category = boost::readable_property_map_tag; // Edges have a weight equal to the average of their endpoint indexes. reference operator[](key_type e) const @@ -409,12 +409,12 @@ struct edge_weight_map // Use these propety_map and property_traits parameterizations to refer to // the associated property map types. -typedef boost::property_map< ring_graph, boost::edge_weight_t >::const_type - const_edge_weight_map; -typedef boost::property_traits< const_edge_weight_map >::reference - edge_weight_map_value_type; -typedef boost::property_traits< const_edge_weight_map >::key_type - edge_weight_map_key; +using const_edge_weight_map + = boost::property_map< ring_graph, boost::edge_weight_t >::const_type; +using edge_weight_map_value_type + = boost::property_traits< const_edge_weight_map >::reference; +using edge_weight_map_key + = boost::property_traits< const_edge_weight_map >::key_type; // PropertyMap valid expressions edge_weight_map_value_type get( diff --git a/example/in_edges.cpp b/example/in_edges.cpp index 1c27aa454..52efc3f91 100644 --- a/example/in_edges.cpp +++ b/example/in_edges.cpp @@ -30,7 +30,7 @@ int main(int, char*[]) using namespace std; using namespace boost; - typedef adjacency_list< listS, vecS, bidirectionalS > Graph; + using Graph = adjacency_list< listS, vecS, bidirectionalS >; const int num_vertices = 5; Graph g(num_vertices); diff --git a/example/inclusive_mean_geodesic.cpp b/example/inclusive_mean_geodesic.cpp index ef88a720a..773b031c0 100644 --- a/example/inclusive_mean_geodesic.cpp +++ b/example/inclusive_mean_geodesic.cpp @@ -24,8 +24,8 @@ template < typename Graph, typename DistanceType, typename ResultType, typename Divides = divides< ResultType > > struct inclusive_average { - typedef DistanceType distance_type; - typedef ResultType result_type; + using distance_type = DistanceType; + using result_type = ResultType; result_type operator()(distance_type d, const Graph& g) { @@ -56,30 +56,30 @@ struct Link }; // Declare the graph type and its vertex and edge types. -typedef directed_graph< WebPage, Link > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = directed_graph< WebPage, Link >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string WebPage::* >::type NameMap; +using NameMap = property_map< Graph, string WebPage::* >::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property< Graph, float > DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property< Graph, float >; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map as an accessor into the bundled // edge property. -typedef property_map< Graph, float Link::* >::type WeightMap; +using WeightMap = property_map< Graph, float Link::* >::type; // Declare a container and its corresponding property map that // will contain the resulting mean geodesic distances of each // vertex in the graph. -typedef exterior_vertex_property< Graph, float > GeodesicProperty; -typedef GeodesicProperty::container_type GeodesicContainer; -typedef GeodesicProperty::map_type GeodesicMap; +using GeodesicProperty = exterior_vertex_property< Graph, float >; +using GeodesicContainer = GeodesicProperty::container_type; +using GeodesicMap = GeodesicProperty::map_type; static float exclusive_geodesics(const Graph&, DistanceMatrixMap, GeodesicMap); static float inclusive_geodesics(const Graph&, DistanceMatrixMap, GeodesicMap); diff --git a/example/incremental-components-eg.cpp b/example/incremental-components-eg.cpp index 7fead1d95..54561ea96 100644 --- a/example/incremental-components-eg.cpp +++ b/example/incremental-components-eg.cpp @@ -20,10 +20,10 @@ using namespace boost; int main(int argc, char* argv[]) { - typedef adjacency_list< vecS, vecS, undirectedS > Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - // typedef graph_traits::edge_descriptor Edge; - typedef graph_traits< Graph >::vertices_size_type VertexIndex; + using Graph = adjacency_list< vecS, vecS, undirectedS >; + using Vertex = graph_traits< Graph >::vertex_descriptor; + // using Edge = graph_traits::edge_descriptor; + using VertexIndex = graph_traits< Graph >::vertices_size_type; // Create a graph const int VERTEX_COUNT = 6; @@ -37,8 +37,8 @@ int main(int argc, char* argv[]) std::vector< Vertex > rank(num_vertices(graph)); std::vector< Vertex > parent(num_vertices(graph)); - typedef VertexIndex* Rank; - typedef Vertex* Parent; + using Rank = VertexIndex*; + using Parent = Vertex*; disjoint_sets< Rank, Parent > ds(&rank[0], &parent[0]); // Determine the connected components, storing the results in the @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) // index map into the component_index constructor if our graph type // used listS instead of vecS (identity_property_map is used by // default). - typedef component_index< VertexIndex > Components; + using Components = component_index< VertexIndex >; Components components(parent.begin(), parent.end()); // Iterate through the component indices diff --git a/example/incremental_components.cpp b/example/incremental_components.cpp index 249e16bde..f22692696 100644 --- a/example/incremental_components.cpp +++ b/example/incremental_components.cpp @@ -49,9 +49,9 @@ using namespace boost; int main(int argc, char* argv[]) { - typedef adjacency_list< vecS, vecS, undirectedS > Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - typedef graph_traits< Graph >::vertices_size_type VertexIndex; + using Graph = adjacency_list< vecS, vecS, undirectedS >; + using Vertex = graph_traits< Graph >::vertex_descriptor; + using VertexIndex = graph_traits< Graph >::vertices_size_type; const int VERTEX_COUNT = 6; Graph graph(VERTEX_COUNT); @@ -59,8 +59,8 @@ int main(int argc, char* argv[]) std::vector< VertexIndex > rank(num_vertices(graph)); std::vector< Vertex > parent(num_vertices(graph)); - typedef VertexIndex* Rank; - typedef Vertex* Parent; + using Rank = VertexIndex*; + using Parent = Vertex*; disjoint_sets< Rank, Parent > ds(&rank[0], &parent[0]); @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) std::cout << std::endl; - typedef component_index< VertexIndex > Components; + using Components = component_index< VertexIndex >; // NOTE: Because we're using vecS for the graph type, we're // effectively using identity_property_map for a vertex index map. diff --git a/example/influence_prestige.cpp b/example/influence_prestige.cpp index b5cc9e92d..c06a3134b 100644 --- a/example/influence_prestige.cpp +++ b/example/influence_prestige.cpp @@ -24,20 +24,20 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef directed_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = directed_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a container type for influence and prestige (both // of which are degree centralities) and its corresponding // property map. -typedef exterior_vertex_property< Graph, unsigned > CentralityProperty; -typedef CentralityProperty::container_type CentralityContainer; -typedef CentralityProperty::map_type CentralityMap; +using CentralityProperty = exterior_vertex_property< Graph, unsigned >; +using CentralityContainer = CentralityProperty::container_type; +using CentralityMap = CentralityProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/interior_pmap_bundled.cpp b/example/interior_pmap_bundled.cpp index 6121e8e24..11c517412 100644 --- a/example/interior_pmap_bundled.cpp +++ b/example/interior_pmap_bundled.cpp @@ -66,9 +66,9 @@ int main() { // Create the graph, and specify that we will use std::string to // store the first name's. - typedef adjacency_list< vecS, vecS, directedS, VertexData > MyGraphType; + using MyGraphType = adjacency_list< vecS, vecS, directedS, VertexData >; - typedef pair< int, int > Pair; + using Pair = pair< int, int >; Pair edge_array[11] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4), Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1), Pair(3, 4), Pair(4, 0), Pair(4, 1) }; diff --git a/example/interior_property_map.cpp b/example/interior_property_map.cpp index 92f3bddf0..4e6fc5801 100644 --- a/example/interior_property_map.cpp +++ b/example/interior_property_map.cpp @@ -59,11 +59,11 @@ template < class EdgeIter, class Graph > void who_owes_who(EdgeIter first, EdgeIter last, const Graph& G) { // Access the propety acessor type for this graph - typedef - typename property_map< Graph, vertex_first_name_t >::const_type NamePA; + using NamePA = + typename property_map< Graph, vertex_first_name_t >::const_type; auto name = get(vertex_first_name, G); - typedef typename boost::property_traits< NamePA >::value_type NameType; + using NameType = typename boost::property_traits< NamePA >::value_type; NameType src_name, targ_name; @@ -81,11 +81,10 @@ int main() { // Create the graph, and specify that we will use std::string to // store the first name's. - typedef adjacency_list< vecS, vecS, directedS, - property< vertex_first_name_t, std::string > > - MyGraphType; + using MyGraphType = adjacency_list< vecS, vecS, directedS, + property< vertex_first_name_t, std::string > >; - typedef pair< int, int > Pair; + using Pair = pair< int, int >; Pair edge_array[11] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4), Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1), Pair(3, 4), Pair(4, 0), Pair(4, 1) }; diff --git a/example/iohb.c b/example/iohb.c index 8a216358d..548ba9224 100644 --- a/example/iohb.c +++ b/example/iohb.c @@ -778,13 +778,13 @@ int writeHB_mat_double(const char* filename, int M, int N, if ( Ptrfmt == NULL ) Ptrfmt = "(8I10)"; ParseIfmt(Ptrfmt,&Ptrperline,&Ptrwidth); - sprintf(pformat,"%%%dd",Ptrwidth); + snprintf(pformat, sizeof(pformat), "%%%dd", Ptrwidth); ptrcrd = (N+1)/Ptrperline; if ( (N+1)%Ptrperline != 0) ptrcrd++; if ( Indfmt == NULL ) Indfmt = Ptrfmt; ParseIfmt(Indfmt,&Indperline,&Indwidth); - sprintf(iformat,"%%%dd",Indwidth); + snprintf(iformat, sizeof(iformat), "%%%dd", Indwidth); indcrd = nz/Indperline; if ( nz%Indperline != 0) indcrd++; @@ -793,9 +793,9 @@ int writeHB_mat_double(const char* filename, int M, int N, ParseRfmt(Valfmt,&Valperline,&Valwidth,&Valprec,&Valflag); if (Valflag == 'D') *strchr(Valfmt,'D') = 'E'; if (Valflag == 'F') - sprintf(vformat,"%% %d.%df",Valwidth,Valprec); + snprintf(vformat, sizeof(vformat), "%% %d.%df", Valwidth, Valprec); else - sprintf(vformat,"%% %d.%dE",Valwidth,Valprec); + snprintf(vformat, sizeof(vformat), "%% %d.%dE", Valwidth, Valprec); valcrd = nvalentries/Valperline; if ( nvalentries%Valperline != 0) valcrd++; } else valcrd = 0; @@ -804,9 +804,9 @@ int writeHB_mat_double(const char* filename, int M, int N, if ( Rhsfmt == NULL ) Rhsfmt = Valfmt; ParseRfmt(Rhsfmt,&Rhsperline,&Rhswidth,&Rhsprec, &Rhsflag); if (Rhsflag == 'F') - sprintf(rformat,"%% %d.%df",Rhswidth,Rhsprec); + snprintf(rformat, sizeof(rformat), "%% %d.%df", Rhswidth, Rhsprec); else - sprintf(rformat,"%% %d.%dE",Rhswidth,Rhsprec); + snprintf(rformat, sizeof(rformat), "%% %d.%dE", Rhswidth, Rhsprec); if (Rhsflag == 'D') *strchr(Rhsfmt,'D') = 'E'; rhscrd = nrhsentries/Rhsperline; if ( nrhsentries%Rhsperline != 0) rhscrd++; @@ -1361,16 +1361,16 @@ int writeHB_mat_char(const char* filename, int M, int N, if ( Ptrfmt == NULL ) Ptrfmt = "(8I10)"; ParseIfmt(Ptrfmt,&Ptrperline,&Ptrwidth); - sprintf(pformat,"%%%dd",Ptrwidth); + snprintf(pformat, sizeof(pformat), "%%%dd", Ptrwidth); if ( Indfmt == NULL ) Indfmt = Ptrfmt; ParseIfmt(Indfmt,&Indperline,&Indwidth); - sprintf(iformat,"%%%dd",Indwidth); + snprintf(iformat, sizeof(iformat), "%%%dd", Indwidth); if ( Type[0] != 'P' ) { /* Skip if pattern only */ if ( Valfmt == NULL ) Valfmt = "(4E20.13)"; ParseRfmt(Valfmt,&Valperline,&Valwidth,&Valprec,&Valflag); - sprintf(vformat,"%%%ds",Valwidth); + snprintf(vformat, sizeof(vformat), "%%%ds", Valwidth); } ptrcrd = (N+1)/Ptrperline; @@ -1385,7 +1385,7 @@ int writeHB_mat_char(const char* filename, int M, int N, if ( Nrhs > 0 ) { if ( Rhsfmt == NULL ) Rhsfmt = Valfmt; ParseRfmt(Rhsfmt,&Rhsperline,&Rhswidth,&Rhsprec, &Rhsflag); - sprintf(rformat,"%%%ds",Rhswidth); + snprintf(rformat, sizeof(rformat), "%%%ds", Rhswidth); rhscrd = nrhsentries/Rhsperline; if ( nrhsentries%Rhsperline != 0) rhscrd++; if ( Rhstype[1] == 'G' ) rhscrd+=rhscrd; diff --git a/example/isomorphism.cpp b/example/isomorphism.cpp index 6a21520b4..a529314a3 100644 --- a/example/isomorphism.cpp +++ b/example/isomorphism.cpp @@ -22,9 +22,8 @@ int main() const int n = 12; - typedef adjacency_list< vecS, listS, undirectedS, - property< vertex_index_t, int > > - graph_t; + using graph_t = adjacency_list< vecS, listS, undirectedS, + property< vertex_index_t, int > >; graph_t g1(n), g2(n); std::vector< graph_traits< graph_t >::vertex_descriptor > v1(n), v2(n); diff --git a/example/johnson-eg.cpp b/example/johnson-eg.cpp index 025bdafe8..30dbd6d67 100644 --- a/example/johnson-eg.cpp +++ b/example/johnson-eg.cpp @@ -18,11 +18,10 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, no_property, - property< edge_weight_t, int, property< edge_weight2_t, int > > > - Graph; + using Graph = adjacency_list< vecS, vecS, directedS, no_property, + property< edge_weight_t, int, property< edge_weight2_t, int > > >; const int V = 6; - typedef std::pair< int, int > Edge; + using Edge = std::pair< int, int >; Edge edge_array[] = { Edge(0, 1), Edge(0, 2), Edge(0, 3), Edge(0, 4), Edge(0, 5), Edge(1, 2), Edge(1, 5), Edge(1, 3), Edge(2, 4), Edge(2, 5), Edge(3, 2), Edge(4, 3), Edge(4, 1), Edge(5, 4) }; diff --git a/example/kevin-bacon.cpp b/example/kevin-bacon.cpp index 97417b038..5f76e0e66 100644 --- a/example/kevin-bacon.cpp +++ b/example/kevin-bacon.cpp @@ -52,17 +52,16 @@ int main(int argc, const char** argv) return EXIT_FAILURE; } - typedef adjacency_list< vecS, vecS, undirectedS, + using Graph = adjacency_list< vecS, vecS, undirectedS, property< vertex_name_t, std::string >, - property< edge_name_t, std::string > > - Graph; + property< edge_name_t, std::string > >; Graph g; auto actor_name = get(vertex_name, g); auto connecting_movie = get(edge_name, g); - typedef graph_traits< Graph >::vertex_descriptor Vertex; - typedef std::map< std::string, Vertex > NameVertexMap; + using Vertex = graph_traits< Graph >::vertex_descriptor; + using NameVertexMap = std::map< std::string, Vertex >; NameVertexMap actors; for (std::string line; std::getline(datafile, line);) diff --git a/example/kevin-bacon2.cpp b/example/kevin-bacon2.cpp index abe88a665..dbdafabf1 100644 --- a/example/kevin-bacon2.cpp +++ b/example/kevin-bacon2.cpp @@ -52,11 +52,10 @@ struct edge_properties using namespace boost; -typedef adjacency_list< vecS, vecS, undirectedS, vertex_properties, - edge_properties > - Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = adjacency_list< vecS, vecS, undirectedS, vertex_properties, + edge_properties >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; class bacon_number_recorder : public default_bfs_visitor { diff --git a/example/king_ordering.cpp b/example/king_ordering.cpp index ad3350915..220c5c981 100644 --- a/example/king_ordering.cpp +++ b/example/king_ordering.cpp @@ -33,14 +33,13 @@ int main(int, char*[]) { using namespace boost; using namespace std; - typedef adjacency_list< vecS, vecS, undirectedS, + using Graph = adjacency_list< vecS, vecS, undirectedS, property< vertex_color_t, default_color_type, - property< vertex_degree_t, int > > > - Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - typedef graph_traits< Graph >::vertices_size_type size_type; + property< vertex_degree_t, int > > >; + using Vertex = graph_traits< Graph >::vertex_descriptor; + using size_type = graph_traits< Graph >::vertices_size_type; - typedef std::pair< std::size_t, std::size_t > Pair; + using Pair = std::pair< std::size_t, std::size_t >; Pair edges[14] = { Pair(0, 3), // a-d Pair(0, 5), // a-f Pair(1, 2), // b-c @@ -98,8 +97,8 @@ int main(int, char*[]) get(vertex_degree, G), get(vertex_index, G)); cout << "King ordering starting at: " << s << endl; cout << " "; - for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (auto const& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) @@ -118,8 +117,8 @@ int main(int, char*[]) cout << "King ordering:" << endl; cout << " "; - for (auto i = inv_perm.begin(); i != inv_perm.end(); ++i) - cout << index_map[*i] << " "; + for (auto const& vertex : inv_perm) + cout << index_map[vertex] << " "; cout << endl; for (size_type c = 0; c != inv_perm.size(); ++c) diff --git a/example/knights_tour.cpp b/example/knights_tour.cpp index 31b8945e7..91bfda831 100644 --- a/example/knights_tour.cpp +++ b/example/knights_tour.cpp @@ -18,7 +18,7 @@ using namespace boost; -typedef std::pair< int, int > Position; +using Position = std::pair< int, int >; Position knight_jumps[8] = { Position(2, -1), Position(1, -2), Position(-1, -2), Position(-2, -1), Position(-2, 1), Position(-1, 2), Position(1, 2), Position(2, 1) }; @@ -59,19 +59,19 @@ struct knight_adjacency_iterator struct knights_tour_graph { - typedef Position vertex_descriptor; - typedef std::pair< vertex_descriptor, vertex_descriptor > edge_descriptor; - typedef knight_adjacency_iterator adjacency_iterator; - typedef void out_edge_iterator; - typedef void in_edge_iterator; - typedef void edge_iterator; - typedef void vertex_iterator; - typedef int degree_size_type; - typedef int vertices_size_type; - typedef int edges_size_type; - typedef directed_tag directed_category; - typedef disallow_parallel_edge_tag edge_parallel_category; - typedef adjacency_graph_tag traversal_category; + using vertex_descriptor = Position; + using edge_descriptor = std::pair< vertex_descriptor, vertex_descriptor >; + using adjacency_iterator = knight_adjacency_iterator; + using out_edge_iterator = void; + using in_edge_iterator = void; + using edge_iterator = void; + using vertex_iterator = void; + using degree_size_type = int; + using vertices_size_type = int; + using edges_size_type = int; + using directed_category = directed_tag; + using edge_parallel_category = disallow_parallel_edge_tag; + using traversal_category = adjacency_graph_tag; knights_tour_graph(int n) : m_board_size(n) {} int m_board_size; }; @@ -98,7 +98,7 @@ std::pair< knights_tour_graph::adjacency_iterator, adjacent_vertices( knights_tour_graph::vertex_descriptor v, const knights_tour_graph& g) { - typedef knights_tour_graph::adjacency_iterator Iter; + using Iter = knights_tour_graph::adjacency_iterator; return std::make_pair(Iter(0, v, g), Iter(8, v, g)); } @@ -115,8 +115,8 @@ bool backtracking_search(Graph& g, typename graph_traits< Graph >::vertex_descriptor src, TimePropertyMap time_map) { - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef std::pair< int, Vertex > P; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using P = std::pair< int, Vertex >; std::stack< P > S; int time_stamp = 0; @@ -171,8 +171,8 @@ template < typename Graph, typename TimePropertyMap > bool warnsdorff(Graph& g, typename graph_traits< Graph >::vertex_descriptor src, TimePropertyMap time_map) { - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef std::pair< int, Vertex > P; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using P = std::pair< int, Vertex >; std::stack< P > S; int time_stamp = 0; @@ -222,9 +222,9 @@ bool warnsdorff(Graph& g, typename graph_traits< Graph >::vertex_descriptor src, struct board_map { - typedef int value_type; - typedef Position key_type; - typedef read_write_property_map_tag category; + using value_type = int; + using key_type = Position; + using category = read_write_property_map_tag; board_map(int* b, int n) : m_board(b), m_size(n) {} friend int get(const board_map& ba, Position p); friend void put(const board_map& ba, Position p, int v); diff --git a/example/kruskal-example.cpp b/example/kruskal-example.cpp index 890f03a13..9433f0906 100644 --- a/example/kruskal-example.cpp +++ b/example/kruskal-example.cpp @@ -13,11 +13,10 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_weight_t, int > > - Graph; - typedef graph_traits< Graph >::edge_descriptor Edge; - typedef std::pair< int, int > E; + using Graph = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_weight_t, int > >; + using Edge = graph_traits< Graph >::edge_descriptor; + using E = std::pair< int, int >; const int num_nodes = 5; E edge_array[] = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), diff --git a/example/kruskal-telephone.cpp b/example/kruskal-telephone.cpp index 78f628962..7e4ae930f 100644 --- a/example/kruskal-telephone.cpp +++ b/example/kruskal-telephone.cpp @@ -26,9 +26,8 @@ int main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_weight_t, int > > - Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_weight_t, int > >; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits< GraphvizGraph >::edge_iterator ei, ei_end; @@ -40,20 +39,20 @@ int main() } std::vector< graph_traits< Graph >::edge_descriptor > mst; - typedef std::vector< graph_traits< Graph >::edge_descriptor >::size_type - size_type; + using size_type + = std::vector< graph_traits< Graph >::edge_descriptor >::size_type; kruskal_minimum_spanning_tree(g, std::back_inserter(mst)); auto weight = get(edge_weight, g); int total_weight = 0; - for (size_type e = 0; e < mst.size(); ++e) - total_weight += get(weight, mst[e]); + for (auto const& edge : mst) + total_weight += get(weight, edge); std::cout << "total weight: " << total_weight << std::endl; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - for (size_type i = 0; i < mst.size(); ++i) + using Vertex = graph_traits< Graph >::vertex_descriptor; + for (auto const& edge : mst) { - auto u = source(mst[i], g), v = target(mst[i], g); + auto u = source(edge, g), v = target(edge, g); edge_attr_map[edge(u, v, g_dot).first]["color"] = "black"; } std::ofstream out("figs/telephone-mst-kruskal.dot"); diff --git a/example/kuratowski_subgraph.cpp b/example/kuratowski_subgraph.cpp index 3ce3f2698..6fe19234c 100644 --- a/example/kuratowski_subgraph.cpp +++ b/example/kuratowski_subgraph.cpp @@ -21,9 +21,8 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int >, property< edge_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int >, property< edge_index_t, int > >; // Create a K_6 (complete graph on 6 vertices), which // contains both Kuratowski subgraphs as minors. @@ -53,8 +52,8 @@ int main(int argc, char** argv) // Test for planarity - we know it is not planar, we just want to // compute the kuratowski subgraph as a side-effect - typedef std::vector< graph_traits< graph >::edge_descriptor > - kuratowski_edges_t; + using kuratowski_edges_t + = std::vector< graph_traits< graph >::edge_descriptor >; kuratowski_edges_t kuratowski_edges; if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::kuratowski_subgraph diff --git a/example/labeled_graph.cpp b/example/labeled_graph.cpp index 6224d768e..0239ef02b 100644 --- a/example/labeled_graph.cpp +++ b/example/labeled_graph.cpp @@ -27,10 +27,10 @@ int main() using namespace boost::graph_detail; - typedef directed_graph<> Digraph; + using Digraph = directed_graph<>; { - typedef labeled_graph< Digraph, unsigned > Graph; + using Graph = labeled_graph< Digraph, unsigned >; Graph g; add_vertex(1, g); add_vertex(2, g); @@ -39,14 +39,14 @@ int main() } { - typedef labeled_graph< Digraph, string > Graph; + using Graph = labeled_graph< Digraph, string >; Graph g; add_vertex("foo", g); add_vertex("bar", g); } { - typedef labeled_graph< Digraph, string, mapS > Graph; + using Graph = labeled_graph< Digraph, string, mapS >; Graph g; add_vertex("foo", g); add_vertex("bar", g); @@ -54,7 +54,7 @@ int main() } { - typedef labeled_graph< Digraph*, int > TempGraph; + using TempGraph = labeled_graph< Digraph*, int >; Digraph g; TempGraph h(&g); add_vertex(12, h); @@ -62,8 +62,8 @@ int main() { // This is actually a fairly complicated specialization. - typedef adjacency_list< vecS, vecS, bidirectionalS > G; - typedef labeled_graph< G, size_t > Graph; + using G = adjacency_list< vecS, vecS, bidirectionalS >; + using Graph = labeled_graph< G, size_t >; Graph g; add_vertex(0, g); add_vertex(1, g); diff --git a/example/last-mod-time.cpp b/example/last-mod-time.cpp index 7001fe4e4..787f97e47 100644 --- a/example/last-mod-time.cpp +++ b/example/last-mod-time.cpp @@ -36,7 +36,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -58,13 +58,12 @@ void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"), @@ -82,16 +81,15 @@ int main(int argc, const char** argv) // Create storage for last modified times std::vector< time_t > last_mod_vec(num_vertices(g)); // Create nickname for the property map type - typedef iterator_property_map< std::vector< time_t >::iterator, - property_map< graph_type, vertex_index_t >::type, time_t, time_t& > - iter_map_t; + using iter_map_t = iterator_property_map< std::vector< time_t >::iterator, + property_map< graph_type, vertex_index_t >::type, time_t, time_t& >; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); auto name = get(vertex_name, g); struct stat stat_buf; graph_traits< graph_type >::vertex_descriptor u; - typedef graph_traits< graph_type >::vertex_iterator vertex_iter_t; + using vertex_iter_t = graph_traits< graph_type >::vertex_iterator; std::pair< vertex_iter_t, vertex_iter_t > p; for (p = vertices(g); p.first != p.second; ++p.first) { diff --git a/example/leda-concept-check.cpp b/example/leda-concept-check.cpp index 490d2d68b..e6aa02c2d 100644 --- a/example/leda-concept-check.cpp +++ b/example/leda-concept-check.cpp @@ -12,7 +12,7 @@ int main() { using namespace boost; - typedef leda::GRAPH< int, int > Graph; + using Graph = leda::GRAPH< int, int >; BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((VertexMutableGraphConcept< Graph >)); diff --git a/example/leda-graph-eg.cpp b/example/leda-graph-eg.cpp index 008349d9f..9d3c48df3 100644 --- a/example/leda-graph-eg.cpp +++ b/example/leda-graph-eg.cpp @@ -11,14 +11,14 @@ int main() { using namespace boost; - typedef leda::GRAPH< std::string, int > graph_t; + using graph_t = leda::GRAPH< std::string, int >; graph_t g; g.new_node("Philoctetes"); g.new_node("Heracles"); g.new_node("Alcmena"); g.new_node("Eurystheus"); g.new_node("Amphitryon"); - typedef property_map< graph_t, vertex_all_t >::type NodeMap; + using NodeMap = property_map< graph_t, vertex_all_t >::type; auto node_name_map = get(vertex_all, g); graph_traits< graph_t >::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) diff --git a/example/loops_dfs.cpp b/example/loops_dfs.cpp index e080307b3..ad28f6710 100644 --- a/example/loops_dfs.cpp +++ b/example/loops_dfs.cpp @@ -57,7 +57,7 @@ void find_loops(typename graph_traits< Graph >::vertex_descriptor entry, Loops& loops) // A container of sets of vertices { BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); - typedef typename graph_traits< Graph >::edge_descriptor Edge; + using Edge = typename graph_traits< Graph >::edge_descriptor; std::vector< Edge > back_edges; std::vector< default_color_type > color_map(num_vertices(g)); depth_first_visit(g, entry, @@ -80,8 +80,8 @@ void compute_loop_extent( Set& loop_set) { BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; - typedef color_traits< default_color_type > Color; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using Color = color_traits< default_color_type >; Vertex loop_head, loop_tail; loop_tail = source(back_edge, g); @@ -117,10 +117,9 @@ int main(int argc, char* argv[]) GraphvizDigraph g_in; read_graphviz(argv[1], g_in); - typedef adjacency_list< vecS, vecS, bidirectionalS, GraphvizVertexProperty, - GraphvizEdgeProperty, GraphvizGraphProperty > - Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; + using Graph = adjacency_list< vecS, vecS, bidirectionalS, + GraphvizVertexProperty, GraphvizEdgeProperty, GraphvizGraphProperty >; + using Vertex = graph_traits< Graph >::vertex_descriptor; Graph g; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -130,8 +129,8 @@ int main(int argc, char* argv[]) copy_graph(g_in, g); - typedef std::set< Vertex > set_t; - typedef std::list< set_t > list_of_sets_t; + using set_t = std::set< Vertex >; + using list_of_sets_t = std::list< set_t >; list_of_sets_t loops; auto entry = *vertices(g).first; diff --git a/example/make_biconnected_planar.cpp b/example/make_biconnected_planar.cpp index bf9a1d186..dfbf1808d 100644 --- a/example/make_biconnected_planar.cpp +++ b/example/make_biconnected_planar.cpp @@ -22,9 +22,8 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int >, property< edge_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int >, property< edge_index_t, int > >; graph g(11); add_edge(0, 1, g); @@ -48,7 +47,7 @@ int main(int argc, char** argv) put(e_index, *ei, edge_count++); // Test for planarity; compute the planar embedding as a side-effect - typedef std::vector< graph_traits< graph >::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits< graph >::edge_descriptor >; std::vector< vec_t > embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = &embedding[0])) @@ -56,11 +55,11 @@ int main(int argc, char** argv) else std::cout << "Input graph is not planar" << std::endl; - typedef std::vector< graph_traits< graph >::edges_size_type > - component_storage_t; - typedef iterator_property_map< component_storage_t::iterator, - property_map< graph, edge_index_t >::type > - component_map_t; + using component_storage_t + = std::vector< graph_traits< graph >::edges_size_type >; + using component_map_t + = iterator_property_map< component_storage_t::iterator, + property_map< graph, edge_index_t >::type >; component_storage_t component_storage(num_edges(g)); component_map_t component(component_storage.begin(), get(edge_index, g)); diff --git a/example/make_connected.cpp b/example/make_connected.cpp index 84491b5e2..afa1edcfe 100644 --- a/example/make_connected.cpp +++ b/example/make_connected.cpp @@ -20,9 +20,8 @@ using namespace boost; int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int > >; graph g(11); add_edge(0, 1, g); diff --git a/example/make_maximal_planar.cpp b/example/make_maximal_planar.cpp index 92b1294d9..b160dfd8f 100644 --- a/example/make_maximal_planar.cpp +++ b/example/make_maximal_planar.cpp @@ -37,9 +37,8 @@ struct face_counter : public planar_face_traversal_visitor int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int >, property< edge_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int >, property< edge_index_t, int > >; // Create the graph - a straight line graph g(10); @@ -67,7 +66,7 @@ int main(int argc, char** argv) put(e_index, *ei, edge_count++); // Test for planarity; compute the planar embedding as a side-effect - typedef std::vector< graph_traits< graph >::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits< graph >::edge_descriptor >; std::vector< vec_t > embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = &embedding[0])) diff --git a/example/matching_example.cpp b/example/matching_example.cpp index a558820dd..9870d8f60 100644 --- a/example/matching_example.cpp +++ b/example/matching_example.cpp @@ -15,7 +15,7 @@ using namespace boost; -typedef adjacency_list< vecS, vecS, undirectedS > my_graph; +using my_graph = adjacency_list< vecS, vecS, undirectedS >; int main() { @@ -25,15 +25,14 @@ int main() const int n_vertices = 18; - std::vector< std::string > ascii_graph; - - ascii_graph.push_back(" 0 1---2 3 "); - ascii_graph.push_back(" \\ / \\ / "); - ascii_graph.push_back(" 4---5 6---7 "); - ascii_graph.push_back(" | | | | "); - ascii_graph.push_back(" 8---9 10---11 "); - ascii_graph.push_back(" / \\ / \\ "); - ascii_graph.push_back(" 12 13 14---15 16 17 "); + std::vector< std::string > ascii_graph + = { " 0 1---2 3 ", + " \\ / \\ / ", + " 4---5 6---7 ", + " | | | | ", + " 8---9 10---11 ", + " / \\ / \\ ", + " 12 13 14---15 16 17 " }; // It has a perfect matching of size 8. There are two isolated // vertices that we'll use later... @@ -75,8 +74,8 @@ int main() std::cout << "In the following graph:" << std::endl << std::endl; - for (auto itr = ascii_graph.begin(); itr != ascii_graph.end(); ++itr) - std::cout << *itr << std::endl; + for (auto const& str : ascii_graph) + std::cout << str << std::endl; std::cout << std::endl << "Found a matching of size " << matching_size(g, &mate[0]) diff --git a/example/max_flow.cpp b/example/max_flow.cpp index ca7eed5e3..0d82d9d53 100644 --- a/example/max_flow.cpp +++ b/example/max_flow.cpp @@ -52,13 +52,12 @@ int main() { using namespace boost; - typedef adjacency_list_traits< vecS, vecS, directedS > Traits; - typedef adjacency_list< listS, vecS, directedS, + using Traits = adjacency_list_traits< vecS, vecS, directedS >; + using Graph = adjacency_list< listS, vecS, directedS, property< vertex_name_t, std::string >, property< edge_capacity_t, long, property< edge_residual_capacity_t, long, - property< edge_reverse_t, Traits::edge_descriptor > > > > - Graph; + property< edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; diff --git a/example/mcgregor_subgraphs_example.cpp b/example/mcgregor_subgraphs_example.cpp index 287a47a9c..98f82d00e 100644 --- a/example/mcgregor_subgraphs_example.cpp +++ b/example/mcgregor_subgraphs_example.cpp @@ -26,7 +26,7 @@ using namespace boost; template < typename Graph > struct example_callback { - typedef typename graph_traits< Graph >::vertices_size_type VertexSizeFirst; + using VertexSizeFirst = typename graph_traits< Graph >::vertices_size_type; example_callback(const Graph& graph1) : m_graph1(graph1) {} @@ -38,9 +38,9 @@ template < typename Graph > struct example_callback { // Fill membership map for first graph - typedef - typename property_map< Graph, vertex_index_t >::type VertexIndexMap; - typedef shared_array_property_map< bool, VertexIndexMap > MembershipMap; + using VertexIndexMap = + typename property_map< Graph, vertex_index_t >::type; + using MembershipMap = shared_array_property_map< bool, VertexIndexMap >; MembershipMap membership_map1( num_vertices(m_graph1), get(vertex_index, m_graph1)); @@ -49,8 +49,9 @@ template < typename Graph > struct example_callback m_graph1, correspondence_map_1_to_2, membership_map1); // Generate filtered graphs using membership map - typedef typename membership_filtered_graph_traits< Graph, - MembershipMap >::graph_type MembershipFilteredGraph; + using MembershipFilteredGraph = + typename membership_filtered_graph_traits< Graph, + MembershipMap >::graph_type; MembershipFilteredGraph subgraph1 = make_membership_filtered_graph(m_graph1, membership_map1); @@ -75,11 +76,10 @@ int main(int argc, char* argv[]) // Using a vecS graph here so that we don't have to mess around with // a vertex index map; it will be implicit. - typedef adjacency_list< listS, vecS, directedS, + using Graph = adjacency_list< listS, vecS, directedS, property< vertex_name_t, unsigned int, property< vertex_index_t, unsigned int > >, - property< edge_name_t, unsigned int > > - Graph; + property< edge_name_t, unsigned int > >; // Test maximum and unique variants on known graphs Graph graph_simple1, graph_simple2; diff --git a/example/mean_geodesic.cpp b/example/mean_geodesic.cpp index 7b41bb3d6..a99a21cb4 100644 --- a/example/mean_geodesic.cpp +++ b/example/mean_geodesic.cpp @@ -24,29 +24,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property< Graph, int > DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property< Graph, int >; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map< Edge, int > WeightMap; +using WeightMap = constant_property_map< Edge, int >; // Declare a container and its corresponding property map that // will contain the resulting mean geodesic distances of each // vertex in the graph. -typedef exterior_vertex_property< Graph, float > GeodesicProperty; -typedef GeodesicProperty::container_type GeodesicContainer; -typedef GeodesicProperty::map_type GeodesicMap; +using GeodesicProperty = exterior_vertex_property< Graph, float >; +using GeodesicContainer = GeodesicProperty::container_type; +using GeodesicMap = GeodesicProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/miles_span.cpp b/example/miles_span.cpp index 66d7cb9a1..b647ae61e 100644 --- a/example/miles_span.cpp +++ b/example/miles_span.cpp @@ -25,7 +25,7 @@ template < class Distance > struct total_length_visitor : public boost::dijkstra_visitor<> { - typedef typename boost::property_traits< Distance >::value_type D; + using D = typename boost::property_traits< Distance >::value_type; total_length_visitor(D& len, Distance d) : _total_length(len), _distance(d) { } diff --git a/example/min_max_paths.cpp b/example/min_max_paths.cpp index 740d31124..7623bd57b 100644 --- a/example/min_max_paths.cpp +++ b/example/min_max_paths.cpp @@ -42,18 +42,17 @@ int main(int, char*[]) { using namespace boost; - typedef adjacency_list< listS, vecS, directedS, no_property, - property< edge_weight_t, int > > - Graph; - typedef graph_traits< Graph >::vertex_descriptor Vertex; + using Graph = adjacency_list< listS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using Vertex = graph_traits< Graph >::vertex_descriptor; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; const char name[] = "abcdef"; const int num_nodes = 6; - E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), - E(4, 0), E(4, 1) }; + const auto edges = { E(0, 2), E(1, 1), E(1, 3), E(1, 4), E(2, 1), E(2, 3), + E(3, 4), E(4, 0), E(4, 1) }; int weights[] = { 1, 2, 1, 2, 7, 3, 1, 1, 1 }; const int n_edges = sizeof(edges) / sizeof(E); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -68,8 +67,8 @@ int main(int, char*[]) weightmap[e] = weights[j]; } #else - Graph G(edges, edges + n_edges, weights, num_nodes); - auto weightmap = get(edge_weight, G); + Graph G(std::begin(edges), std::end(edges), weights, num_nodes); + auto = get(edge_weight, G); #endif std::vector< Vertex > p(num_vertices(G)); diff --git a/example/minimum_degree_ordering.cpp b/example/minimum_degree_ordering.cpp index 38044a166..0b22ea5f2 100644 --- a/example/minimum_degree_ordering.cpp +++ b/example/minimum_degree_ordering.cpp @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) harwell_boeing hbs(argv[1]); // must be BGL directed graph now - typedef adjacency_list< vecS, vecS, directedS > Graph; + using Graph = adjacency_list< vecS, vecS, directedS >; int n = hbs.nrows(); @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) cout << "number of off-diagnal elements: " << num_edge << endl; - typedef std::vector< int > Vector; + using Vector = std::vector< int >; Vector inverse_perm(n, 0); Vector perm(n, 0); diff --git a/example/modify_graph.cpp b/example/modify_graph.cpp index acad2c47b..04ccc7331 100644 --- a/example/modify_graph.cpp +++ b/example/modify_graph.cpp @@ -40,9 +40,9 @@ inline name_equals_predicate< NamePropertyMap > name_equals( template < class MutableGraph > void modify_demo(MutableGraph& g) { - typedef graph_traits< MutableGraph > GraphTraits; - typedef typename GraphTraits::vertices_size_type size_type; - typedef typename GraphTraits::edge_descriptor edge_descriptor; + using GraphTraits = graph_traits< MutableGraph >; + using size_type = typename GraphTraits::vertices_size_type; + using edge_descriptor = typename GraphTraits::edge_descriptor; size_type n = 0; typename GraphTraits::edges_size_type m = 0; typename GraphTraits::vertex_descriptor u, v, w; diff --git a/example/neighbor_bfs.cpp b/example/neighbor_bfs.cpp index ca3e2d76a..a7b8023cc 100644 --- a/example/neighbor_bfs.cpp +++ b/example/neighbor_bfs.cpp @@ -53,8 +53,8 @@ template < class ParentDecorator > struct print_parent template < class DistanceMap, class PredecessorMap, class ColorMap > class distance_and_pred_visitor : public neighbor_bfs_visitor<> { - typedef typename property_traits< ColorMap >::value_type ColorValue; - typedef color_traits< ColorValue > Color; + using ColorValue = typename property_traits< ColorMap >::value_type; + using Color = color_traits< ColorValue >; public: distance_and_pred_visitor(DistanceMap d, PredecessorMap p, ColorMap c) @@ -84,11 +84,10 @@ class distance_and_pred_visitor : public neighbor_bfs_visitor<> int main(int, char*[]) { - typedef adjacency_list< mapS, vecS, bidirectionalS, - property< vertex_color_t, default_color_type > > - Graph; + using Graph = adjacency_list< mapS, vecS, bidirectionalS, + property< vertex_color_t, default_color_type > >; - typedef property_map< Graph, vertex_color_t >::type ColorMap; + using ColorMap = property_map< Graph, vertex_color_t >::type; Graph G(5); add_edge(0, 2, G); @@ -103,19 +102,19 @@ int main(int, char*[]) add_edge(4, 0, G); add_edge(4, 1, G); - typedef Graph::vertex_descriptor Vertex; + using Vertex = Graph::vertex_descriptor; // Array to store predecessor (parent) of each vertex. This will be // used as a Decorator (actually, its iterator will be). std::vector< Vertex > p(num_vertices(G)); // VC++ version of std::vector has no ::pointer, so // I use ::value_type* instead. - typedef std::vector< Vertex >::value_type* Piter; + using Piter = std::vector< Vertex >::value_type*; // Array to store distances from the source to each vertex . We use // a built-in array here just for variety. This will also be used as // a Decorator. - typedef graph_traits< Graph >::vertices_size_type size_type; + using size_type = graph_traits< Graph >::vertices_size_type; size_type d[5]; std::fill_n(d, 5, 0); diff --git a/example/ordered_out_edges.cpp b/example/ordered_out_edges.cpp index 16003f88f..fda38539d 100644 --- a/example/ordered_out_edges.cpp +++ b/example/ordered_out_edges.cpp @@ -42,9 +42,9 @@ template < class StoredEdge > struct order_by_name { - typedef StoredEdge first_argument_type; - typedef StoredEdge second_argument_type; - typedef bool result_type; + using first_argument_type = StoredEdge; + using second_argument_type = StoredEdge; + using result_type = bool; bool operator()(const StoredEdge& e1, const StoredEdge& e2) const { // Order by target vertex, then by name. @@ -64,7 +64,7 @@ namespace boost template < class ValueType > struct container_gen< ordered_set_by_nameS, ValueType > { - typedef std::multiset< ValueType, order_by_name< ValueType > > type; + using type = std::multiset< ValueType, order_by_name< ValueType > >; }; } #else @@ -72,14 +72,16 @@ struct ordered_set_by_nameS { template < class T > struct bind_ { - typedef std::multiset< T, order_by_name< T > > type; - }; + using + } = std::multiset< T, order_by_name< T > > type; + ; +}; }; namespace boost { template <> struct container_selector< ordered_set_by_nameS > { - typedef ordered_set_by_nameS type; + using type = ordered_set_by_nameS; }; } #endif @@ -88,7 +90,7 @@ namespace boost { template <> struct parallel_edge_traits< ordered_set_by_nameS > { - typedef allow_parallel_edge_tag type; + using type = allow_parallel_edge_tag; }; } @@ -98,10 +100,9 @@ int main() std::cout << "This program requires partial specialization" << std::endl; #else using namespace boost; - typedef property< edge_name_t, std::string > EdgeProperty; - typedef adjacency_list< ordered_set_by_nameS, vecS, undirectedS, - no_property, EdgeProperty > - graph_type; + using EdgeProperty = property< edge_name_t, std::string >; + using graph_type = adjacency_list< ordered_set_by_nameS, vecS, undirectedS, + no_property, EdgeProperty >; graph_type g; add_edge(0, 1, EdgeProperty("joe"), g); @@ -128,7 +129,7 @@ int main() std::cout << std::endl; bool found; - typedef graph_traits< graph_type > Traits; + using Traits = graph_traits< graph_type >; Traits::edge_descriptor e; Traits::out_edge_iterator e_first, e_last; diff --git a/example/ospf-example.cpp b/example/ospf-example.cpp index d0b44df2a..411fc9c3a 100644 --- a/example/ospf-example.cpp +++ b/example/ospf-example.cpp @@ -22,11 +22,10 @@ BOOST_INSTALL_PROPERTY(graph, color); int main(int argc, const char** argv) { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, + using g_dot_type = adjacency_list< vecS, vecS, directedS, property< vertex_name_t, std::string >, property< edge_color_t, std::string, property< edge_weight_t, int > >, - property< graph_color_t, std::string > > - g_dot_type; + property< graph_color_t, std::string > >; g_dot_type g_dot; dynamic_properties dp(ignore_other_properties); @@ -41,10 +40,9 @@ int main(int argc, const char** argv) read_graphviz(infile, g_dot, dp); } - typedef adjacency_list< vecS, vecS, directedS, no_property, - property< edge_weight_t, int > > - Graph; - typedef graph_traits< Graph >::vertex_descriptor vertex_descriptor; + using Graph = adjacency_list< vecS, vecS, directedS, no_property, + property< edge_weight_t, int > >; + using vertex_descriptor = graph_traits< Graph >::vertex_descriptor; Graph g(num_vertices(g_dot)); graph_traits< g_dot_type >::edge_iterator ei, ei_end; for (boost::tie(ei, ei_end) = edges(g_dot); ei != ei_end; ++ei) @@ -65,7 +63,7 @@ int main(int argc, const char** argv) std::vector< vertex_descriptor > parent(num_vertices(g)); // All vertices start out as there own parent - typedef graph_traits< Graph >::vertices_size_type size_type; + using size_type = graph_traits< Graph >::vertices_size_type; for (size_type p = 0; p < num_vertices(g); ++p) parent[p] = p; diff --git a/example/parallel-compile-time.cpp b/example/parallel-compile-time.cpp index 22c6e4795..e3ee3bf46 100644 --- a/example/parallel-compile-time.cpp +++ b/example/parallel-compile-time.cpp @@ -36,27 +36,27 @@ BOOST_INSTALL_PROPERTY(vertex, compile_cost); using namespace boost; -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - listS, // Store vertex set in a std::list - directedS, // The file dependency graph is directed - // vertex properties - property< vertex_name_t, std::string, - property< vertex_compile_cost_t, float, - property< vertex_distance_t, float, - property< vertex_color_t, default_color_type > > > >, - // an edge property - property< edge_weight_t, float > > - file_dep_graph2; - -typedef graph_traits< file_dep_graph2 >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph2 >::edge_descriptor edge_t; +using file_dep_graph2 + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + listS, // Store vertex set in a std::list + directedS, // The file dependency graph is directed + // vertex properties + property< vertex_name_t, std::string, + property< vertex_compile_cost_t, float, + property< vertex_distance_t, float, + property< vertex_color_t, default_color_type > > > >, + // an edge property + property< edge_weight_t, float > >; + +using vertex_t = graph_traits< file_dep_graph2 >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph2 >::edge_descriptor; template < typename Graph, typename ColorMap, typename Visitor > void dfs_v2(const Graph& g, typename graph_traits< Graph >::vertex_descriptor u, ColorMap color, Visitor vis) { - typedef typename property_traits< ColorMap >::value_type color_type; - typedef color_traits< color_type > ColorT; + using color_type = typename property_traits< ColorMap >::value_type; + using ColorT = color_traits< color_type >; color[u] = ColorT::gray(); vis.discover_vertex(u, g); typename graph_traits< Graph >::out_edge_iterator ei, ei_end; @@ -77,8 +77,8 @@ void dfs_v2(const Graph& g, typename graph_traits< Graph >::vertex_descriptor u, template < typename Graph, typename Visitor, typename ColorMap > void generic_dfs_v2(const Graph& g, Visitor vis, ColorMap color) { - typedef typename property_traits< ColorMap >::value_type ColorValue; - typedef color_traits< ColorValue > ColorT; + using ColorValue = typename property_traits< ColorMap >::value_type; + using ColorT = color_traits< ColorValue >; typename graph_traits< Graph >::vertex_iterator vi, vi_end; for (boost::tie(vi, vi_end) = vertices(g); vi != vi_end; ++vi) color[*vi] = ColorT::white(); @@ -107,16 +107,16 @@ void topo_sort(const Graph& g, OutputIterator topo_order, ColorMap color) generic_dfs_v2(g, vis, color); } -typedef property_map< file_dep_graph2, vertex_name_t >::type name_map_t; -typedef property_map< file_dep_graph2, vertex_compile_cost_t >::type - compile_cost_map_t; -typedef property_map< file_dep_graph2, vertex_distance_t >::type distance_map_t; -typedef property_map< file_dep_graph2, vertex_color_t >::type color_map_t; +using name_map_t = property_map< file_dep_graph2, vertex_name_t >::type; +using compile_cost_map_t + = property_map< file_dep_graph2, vertex_compile_cost_t >::type; +using distance_map_t = property_map< file_dep_graph2, vertex_distance_t >::type; +using color_map_t = property_map< file_dep_graph2, vertex_color_t >::type; int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph2 >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph2 >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator< std::pair< size_type, size_type > > input_begin( @@ -125,7 +125,7 @@ int main(int argc, const char** argv) #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 // VC++ can't handle the iterator constructor file_dep_graph2 g; - typedef graph_traits< file_dep_graph2 >::vertex_descriptor vertex_t; + using vertex_t = graph_traits< file_dep_graph2 >::vertex_descriptor; std::vector< vertex_t > id2vertex; for (std::size_t v = 0; v < n_vertices; ++v) id2vertex.push_back(add_vertex(g)); diff --git a/example/planar_face_traversal.cpp b/example/planar_face_traversal.cpp index e96e9c3bf..90ba2a31e 100644 --- a/example/planar_face_traversal.cpp +++ b/example/planar_face_traversal.cpp @@ -43,9 +43,8 @@ struct edge_output_visitor : public output_visitor int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int >, property< edge_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int >, property< edge_index_t, int > >; // Create a graph - this is a biconnected, 3 x 3 grid. // It should have four small (four vertex/four edge) faces and @@ -79,7 +78,7 @@ int main(int argc, char** argv) // Test for planarity - we know it is planar, we just want to // compute the planar embedding as a side-effect - typedef std::vector< graph_traits< graph >::edge_descriptor > vec_t; + using vec_t = std::vector< graph_traits< graph >::edge_descriptor >; std::vector< vec_t > embedding(num_vertices(g)); if (boyer_myrvold_planarity_test(boyer_myrvold_params::graph = g, boyer_myrvold_params::embedding = &embedding[0])) diff --git a/example/prim-example.cpp b/example/prim-example.cpp index ad44df9b4..b93daa536 100644 --- a/example/prim-example.cpp +++ b/example/prim-example.cpp @@ -13,12 +13,11 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_distance_t, int >, property< edge_weight_t, int > > - Graph; - typedef std::pair< int, int > E; + using Graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_distance_t, int >, property< edge_weight_t, int > >; + using E = std::pair< int, int >; const int num_nodes = 5; - E edges[] + const auto edges = { E(0, 2), E(1, 3), E(1, 4), E(2, 1), E(2, 3), E(3, 4), E(4, 0) }; int weights[] = { 1, 1, 2, 7, 3, 1, 1 }; #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 @@ -32,7 +31,7 @@ int main() weightmap[e] = weights[j]; } #else - Graph g(edges, edges + sizeof(edges) / sizeof(E), weights, num_nodes); + Graph g(std::begin(edges), std::end(edges), weights, num_nodes); #endif std::vector< graph_traits< Graph >::vertex_descriptor > p(num_vertices(g)); diff --git a/example/prim-telephone.cpp b/example/prim-telephone.cpp index e5dd4df9d..ba895a1e1 100644 --- a/example/prim-telephone.cpp +++ b/example/prim-telephone.cpp @@ -26,9 +26,8 @@ int main() GraphvizGraph g_dot; read_graphviz("figs/telephone-network.dot", g_dot); - typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_weight_t, int > > - Graph; + using Graph = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_weight_t, int > >; Graph g(num_vertices(g_dot)); auto edge_attr_map = get(edge_attribute, g_dot); graph_traits< GraphvizGraph >::edge_iterator ei, ei_end; @@ -39,7 +38,7 @@ int main() add_edge(source(*ei, g_dot), target(*ei, g_dot), edge_property, g); } - typedef graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = graph_traits< Graph >::vertex_descriptor; std::vector< Vertex > parent(num_vertices(g)); auto weight = get(edge_weight, g); #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 diff --git a/example/print-adjacent-vertices.cpp b/example/print-adjacent-vertices.cpp index 22b0ba656..f12503626 100644 --- a/example/print-adjacent-vertices.cpp +++ b/example/print-adjacent-vertices.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -76,13 +76,12 @@ inline name_equals_t< NameMap > name_equals( int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name diff --git a/example/print-edges.cpp b/example/print-edges.cpp index 20d4e1900..33c1ca2d1 100644 --- a/example/print-edges.cpp +++ b/example/print-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -49,13 +49,12 @@ void print_dependencies( int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name diff --git a/example/print-in-edges.cpp b/example/print-in-edges.cpp index f45ecde1a..527d87a04 100644 --- a/example/print-in-edges.cpp +++ b/example/print-in-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -74,14 +74,13 @@ inline name_equals_t< NameMap > name_equals( int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector bidirectionalS, // The graph is directed, with both out-edges and // in-edges property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name diff --git a/example/print-out-edges.cpp b/example/print-out-edges.cpp index 8c97205d2..a2598dfb3 100644 --- a/example/print-out-edges.cpp +++ b/example/print-out-edges.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -74,13 +74,12 @@ inline name_equals_t< NameMap > name_equals( int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name @@ -107,7 +106,7 @@ int main(int argc, const char** argv) graph_traits< graph_type >::vertex_iterator i, end; boost::tie(i, end) = vertices(g); - typedef property_map< graph_type, vertex_name_t >::type name_map_t; + using name_map_t = property_map< graph_type, vertex_name_t >::type; name_equals_t< name_map_t > predicate("dax.h", get(vertex_name, g)); i = std::find_if(i, end, predicate); output_out_edges(std::cout, g, *i, get(vertex_name, g)); diff --git a/example/property-map-traits-eg.cpp b/example/property-map-traits-eg.cpp index 7c86caac2..0ddeee5a2 100644 --- a/example/property-map-traits-eg.cpp +++ b/example/property-map-traits-eg.cpp @@ -12,9 +12,8 @@ int main() { using namespace boost; - typedef adjacency_list< listS, listS, directedS, - property< vertex_name_t, std::string > > - graph_t; + using graph_t = adjacency_list< listS, listS, directedS, + property< vertex_name_t, std::string > >; graph_t g; graph_traits< graph_t >::vertex_descriptor u = add_vertex(g); auto name_map = get(vertex_name, g); diff --git a/example/property_iterator.cpp b/example/property_iterator.cpp index 286b81b11..b3f55fd13 100644 --- a/example/property_iterator.cpp +++ b/example/property_iterator.cpp @@ -25,9 +25,9 @@ struct toto_t { num = 23063 }; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< toto_t, double > Toto; +using Toto = property< toto_t, double >; struct radius_t { @@ -35,9 +35,9 @@ struct radius_t { num = 23062 }; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< radius_t, double, Toto > Radius; +using Radius = property< radius_t, double, Toto >; struct mass_t { @@ -45,9 +45,9 @@ struct mass_t { num = 23061 }; - typedef vertex_property_tag kind; + using kind = vertex_property_tag; }; -typedef property< mass_t, int, Radius > Mass; +using Mass = property< mass_t, int, Radius >; //====== edge properties struct stiff_t @@ -56,16 +56,15 @@ struct stiff_t { num = 23064 }; - typedef edge_property_tag kind; + using kind = edge_property_tag; }; -typedef property< stiff_t, double > Stiff; +using Stiff = property< stiff_t, double >; //===== graph type -typedef Mass VertexProperty; -typedef Stiff EdgeProperty; -typedef adjacency_list< vecS, setS, bidirectionalS, VertexProperty, - EdgeProperty > - Graph; +using VertexProperty = Mass; +using EdgeProperty = Stiff; +using Graph = adjacency_list< vecS, setS, bidirectionalS, VertexProperty, + EdgeProperty >; //===== utilities struct Print diff --git a/example/push-relabel-eg.cpp b/example/push-relabel-eg.cpp index cf146de1e..01d0d9eba 100644 --- a/example/push-relabel-eg.cpp +++ b/example/push-relabel-eg.cpp @@ -47,13 +47,12 @@ int main() { using namespace boost; - typedef adjacency_list_traits< vecS, vecS, directedS > Traits; - typedef adjacency_list< vecS, vecS, directedS, + using Traits = adjacency_list_traits< vecS, vecS, directedS >; + using Graph = adjacency_list< vecS, vecS, directedS, property< vertex_name_t, std::string >, property< edge_capacity_t, long, property< edge_residual_capacity_t, long, - property< edge_reverse_t, Traits::edge_descriptor > > > > - Graph; + property< edge_reverse_t, Traits::edge_descriptor > > > >; Graph g; auto capacity = get(edge_capacity, g); diff --git a/example/put-get-helper-eg.cpp b/example/put-get-helper-eg.cpp index ae736ba10..c0950453b 100644 --- a/example/put-get-helper-eg.cpp +++ b/example/put-get-helper-eg.cpp @@ -24,12 +24,12 @@ class iterator_property_map iterator_property_map< RandomAccessIterator, IndexMap > > { public: - typedef std::ptrdiff_t key_type; - typedef typename std::iterator_traits< RandomAccessIterator >::value_type - value_type; - typedef typename std::iterator_traits< RandomAccessIterator >::reference - reference; - typedef boost::lvalue_property_map_tag category; + using key_type = std::ptrdiff_t; + using value_type = + typename std::iterator_traits< RandomAccessIterator >::value_type; + using reference = + typename std::iterator_traits< RandomAccessIterator >::reference; + using category = boost::lvalue_property_map_tag; iterator_property_map(RandomAccessIterator cc = RandomAccessIterator(), const IndexMap& _id = IndexMap()) @@ -50,10 +50,9 @@ class iterator_property_map int main() { - typedef std::vector< std::string > vec_t; - typedef foo::iterator_property_map< vec_t::iterator, - boost::identity_property_map > - pmap_t; + using vec_t = std::vector< std::string >; + using pmap_t = foo::iterator_property_map< vec_t::iterator, + boost::identity_property_map >; using namespace boost; BOOST_CONCEPT_ASSERT((Mutable_LvaluePropertyMapConcept< pmap_t, int >)); return 0; diff --git a/example/quick-tour.cpp b/example/quick-tour.cpp index 85f3c5189..63cb561fa 100644 --- a/example/quick-tour.cpp +++ b/example/quick-tour.cpp @@ -31,7 +31,7 @@ template < typename Graph, typename VertexNameMap > void print_vertex_names(const Graph& g, VertexNameMap name_map) { std::cout << "vertices(g) = { "; - typedef typename graph_traits< Graph >::vertex_iterator iter_t; + using iter_t = typename graph_traits< Graph >::vertex_iterator; for (auto p = vertices(g); p.first != p.second; ++p.first) { print_vertex_name(*p.first, name_map); @@ -89,9 +89,8 @@ void build_router_network( int main() { - typedef adjacency_list< listS, listS, directedS, - property< vertex_name_t, char >, property< edge_weight_t, double > > - graph_t; + using graph_t = adjacency_list< listS, listS, directedS, + property< vertex_name_t, char >, property< edge_weight_t, double > >; graph_t g; auto name_map = get(vertex_name, g); diff --git a/example/quick_tour.cpp b/example/quick_tour.cpp index f952c976b..25369663a 100644 --- a/example/quick_tour.cpp +++ b/example/quick_tour.cpp @@ -20,7 +20,7 @@ using namespace boost; template < class Graph > struct exercise_vertex { exercise_vertex(Graph& g_, const char name_[]) : g(g_), name(name_) {} - typedef typename graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = typename graph_traits< Graph >::vertex_descriptor; void operator()(const Vertex& v) const { using namespace boost; @@ -67,10 +67,9 @@ template < class Graph > struct exercise_vertex int main(int, char*[]) { - // create a typedef for the Graph type - typedef adjacency_list< vecS, vecS, bidirectionalS, no_property, - property< edge_weight_t, float > > - Graph; + // create an alias for the Graph type + using Graph = adjacency_list< vecS, vecS, bidirectionalS, no_property, + property< edge_weight_t, float > >; // Make convenient labels for the vertices enum @@ -86,7 +85,7 @@ int main(int, char*[]) const char name[] = "ABCDE"; // writing out the edges in the graph - typedef std::pair< int, int > Edge; + using Edge = std::pair< int, int >; Edge edge_array[] = { Edge(A, B), Edge(A, D), @@ -125,7 +124,7 @@ int main(int, char*[]) = get(edge_weight, g); std::cout << "vertices(g) = "; - typedef graph_traits< Graph >::vertex_iterator vertex_iter; + using vertex_iter = graph_traits< Graph >::vertex_iterator; std::pair< vertex_iter, vertex_iter > vp; for (vp = vertices(g); vp.first != vp.second; ++vp.first) std::cout << name[get(vertex_id, *vp.first)] << " "; diff --git a/example/r_c_shortest_paths_example.cpp b/example/r_c_shortest_paths_example.cpp index 747481f5c..77326bb7c 100644 --- a/example/r_c_shortest_paths_example.cpp +++ b/example/r_c_shortest_paths_example.cpp @@ -43,9 +43,8 @@ struct SPPRC_Example_Graph_Arc_Prop int time; }; -typedef adjacency_list< vecS, vecS, directedS, SPPRC_Example_Graph_Vert_Prop, - SPPRC_Example_Graph_Arc_Prop > - SPPRC_Example_Graph; +using SPPRC_Example_Graph = adjacency_list< vecS, vecS, directedS, + SPPRC_Example_Graph_Vert_Prop, SPPRC_Example_Graph_Arc_Prop >; // data structures for spp without resource constraints: // ResourceContainer model diff --git a/example/reachable-loop-head.cpp b/example/reachable-loop-head.cpp index aa05ab0a1..6c4b40f4b 100644 --- a/example/reachable-loop-head.cpp +++ b/example/reachable-loop-head.cpp @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) GraphvizDigraph g; read_graphviz(argv[1], g); graph_traits< GraphvizDigraph >::vertex_descriptor loop_head = 1; - typedef color_traits< default_color_type > Color; + using Color = color_traits< default_color_type >; std::vector< default_color_type > reachable_from_head( num_vertices(g), Color::white()); diff --git a/example/reachable-loop-tail.cpp b/example/reachable-loop-tail.cpp index 2d9f3dd3d..c49f98478 100644 --- a/example/reachable-loop-tail.cpp +++ b/example/reachable-loop-tail.cpp @@ -34,14 +34,13 @@ int main(int argc, char* argv[]) GraphvizDigraph g_in; read_graphviz(argv[1], g_in); - typedef adjacency_list< vecS, vecS, bidirectionalS, GraphvizVertexProperty, - GraphvizEdgeProperty, GraphvizGraphProperty > - Graph; + using Graph = adjacency_list< vecS, vecS, bidirectionalS, + GraphvizVertexProperty, GraphvizEdgeProperty, GraphvizGraphProperty >; Graph g; copy_graph(g_in, g); graph_traits< GraphvizDigraph >::vertex_descriptor loop_tail = 6; - typedef color_traits< default_color_type > Color; + using Color = color_traits< default_color_type >; default_color_type c; std::vector< default_color_type > reachable_to_tail(num_vertices(g)); diff --git a/example/read_graphviz.cpp b/example/read_graphviz.cpp index 3b6348a43..36b3a1f04 100644 --- a/example/read_graphviz.cpp +++ b/example/read_graphviz.cpp @@ -20,16 +20,15 @@ using namespace std; int main() { // Vertex properties - typedef property< vertex_name_t, std::string, - property< vertex_color_t, float > > - vertex_p; + using vertex_p = property< vertex_name_t, std::string, + property< vertex_color_t, float > >; // Edge properties - typedef property< edge_weight_t, double > edge_p; + using edge_p = property< edge_weight_t, double >; // Graph properties - typedef property< graph_name_t, std::string > graph_p; + using graph_p = property< graph_name_t, std::string >; // adjacency_list-based type - typedef adjacency_list< vecS, vecS, directedS, vertex_p, edge_p, graph_p > - graph_t; + using graph_t + = adjacency_list< vecS, vecS, directedS, vertex_p, edge_p, graph_p >; // Construct an empty graph and prepare the dynamic_property_maps. graph_t graph(0); diff --git a/example/read_write_dimacs-eg.cpp b/example/read_write_dimacs-eg.cpp index 9d7f670c5..3ebddc79f 100644 --- a/example/read_write_dimacs-eg.cpp +++ b/example/read_write_dimacs-eg.cpp @@ -63,20 +63,19 @@ template < typename EdgeCapacityMap > struct zero_edge_capacity int main() { using namespace boost; - typedef adjacency_list_traits< vecS, vecS, directedS > Traits; - typedef adjacency_list< vecS, vecS, directedS, no_property, + using Traits = adjacency_list_traits< vecS, vecS, directedS >; + using Graph = adjacency_list< vecS, vecS, directedS, no_property, property< edge_capacity_t, long, - property< edge_reverse_t, Traits::edge_descriptor > > > - Graph; + property< edge_reverse_t, Traits::edge_descriptor > > >; - typedef graph_traits< Graph >::out_edge_iterator out_edge_iterator; - typedef graph_traits< Graph >::edge_descriptor edge_descriptor; - typedef graph_traits< Graph >::vertex_descriptor vertex_descriptor; + using out_edge_iterator = graph_traits< Graph >::out_edge_iterator; + using edge_descriptor = graph_traits< Graph >::edge_descriptor; + using vertex_descriptor = graph_traits< Graph >::vertex_descriptor; Graph g; - typedef property_map< Graph, edge_capacity_t >::type tCapMap; - typedef tCapMap::value_type tCapMapValue; + using tCapMap = property_map< Graph, edge_capacity_t >::type; + using tCapMapValue = tCapMap::value_type; auto capacity = get(edge_capacity, g); auto rev = get(edge_reverse, g); diff --git a/example/remove_edge_if_bidir.cpp b/example/remove_edge_if_bidir.cpp index 9be499fdc..76b8044ae 100644 --- a/example/remove_edge_if_bidir.cpp +++ b/example/remove_edge_if_bidir.cpp @@ -40,9 +40,8 @@ using namespace boost; -typedef adjacency_list< vecS, vecS, bidirectionalS, no_property, - property< edge_weight_t, int > > - Graph; +using Graph = adjacency_list< vecS, vecS, bidirectionalS, no_property, + property< edge_weight_t, int > >; struct has_weight_greater_than { @@ -63,7 +62,7 @@ struct has_weight_greater_than int main() { - typedef std::pair< std::size_t, std::size_t > Edge; + using Edge = std::pair< std::size_t, std::size_t >; Edge edge_array[6] = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3), Edge(2, 0), Edge(3, 2) }; diff --git a/example/remove_edge_if_dir.cpp b/example/remove_edge_if_dir.cpp index 825e409bd..411ba84f2 100644 --- a/example/remove_edge_if_dir.cpp +++ b/example/remove_edge_if_dir.cpp @@ -36,22 +36,15 @@ using namespace boost; -typedef adjacency_list< vecS, vecS, directedS > Graph; +using Graph = adjacency_list< vecS, vecS, directedS >; int main() { - typedef std::pair< std::size_t, std::size_t > Edge; - Edge edges[6] = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3), + using Edge = std::pair< std::size_t, std::size_t >; + const auto edges = { Edge(0, 3), Edge(0, 2), Edge(0, 3), Edge(1, 3), Edge(2, 0), Edge(3, 2) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - // VC++ can't handle iterator constructor - Graph g(4); - for (std::size_t j = 0; j < 6; ++j) - add_edge(edges[j].first, edges[j].second, g); -#else - Graph g(edges, edges + 6, 4); -#endif + Graph g(std::begin(edges), std::end(edges), 4); std::cout << "original graph:" << std::endl; print_graph(g, get(vertex_index, g)); diff --git a/example/remove_edge_if_undir.cpp b/example/remove_edge_if_undir.cpp index 0d5f49b37..cb0cc82de 100644 --- a/example/remove_edge_if_undir.cpp +++ b/example/remove_edge_if_undir.cpp @@ -39,9 +39,8 @@ using namespace boost; */ -typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_weight_t, int > > - Graph; +using Graph = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_weight_t, int > >; struct has_weight_greater_than { @@ -62,7 +61,7 @@ struct has_weight_greater_than int main() { - typedef std::pair< std::size_t, std::size_t > Edge; + using Edge = std::pair< std::size_t, std::size_t >; Edge edge_array[5] = { Edge(0, 3), Edge(0, 3), Edge(1, 3), Edge(2, 0), Edge(3, 2) }; diff --git a/example/reverse_graph.cpp b/example/reverse_graph.cpp index be840bd0b..fb5531b91 100644 --- a/example/reverse_graph.cpp +++ b/example/reverse_graph.cpp @@ -19,7 +19,7 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, bidirectionalS > Graph; + using Graph = adjacency_list< vecS, vecS, bidirectionalS >; Graph G(5); add_edge(0, 2, G); diff --git a/example/roget_components.cpp b/example/roget_components.cpp index a90b1a9dd..d3c12c431 100644 --- a/example/roget_components.cpp +++ b/example/roget_components.cpp @@ -19,7 +19,7 @@ int main(int argc, char* argv[]) { using namespace boost; Graph* g; - typedef graph_traits< Graph* >::vertex_descriptor vertex_t; + using vertex_t = graph_traits< Graph* >::vertex_descriptor; unsigned long n = 0; unsigned long d = 0; unsigned long p = 0; diff --git a/example/scaled_closeness_centrality.cpp b/example/scaled_closeness_centrality.cpp index 1f349f682..ae20c4264 100644 --- a/example/scaled_closeness_centrality.cpp +++ b/example/scaled_closeness_centrality.cpp @@ -27,8 +27,8 @@ template < typename Graph, typename Distance, typename Result, typename Divide = divides< Result > > struct scaled_closeness_measure { - typedef Distance distance_type; - typedef Result result_type; + using distance_type = Distance; + using result_type = Result; Result operator()(Distance d, const Graph& g) { @@ -51,29 +51,29 @@ struct Actor }; // Declare the graph type and its vertex and edge types. -typedef undirected_graph< Actor > Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = undirected_graph< Actor >; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; // The name map provides an abstract accessor for the names of // each vertex. This is used during graph creation. -typedef property_map< Graph, string Actor::* >::type NameMap; +using NameMap = property_map< Graph, string Actor::* >::type; // Declare a matrix type and its corresponding property map that // will contain the distances between each pair of vertices. -typedef exterior_vertex_property< Graph, int > DistanceProperty; -typedef DistanceProperty::matrix_type DistanceMatrix; -typedef DistanceProperty::matrix_map_type DistanceMatrixMap; +using DistanceProperty = exterior_vertex_property< Graph, int >; +using DistanceMatrix = DistanceProperty::matrix_type; +using DistanceMatrixMap = DistanceProperty::matrix_map_type; // Declare the weight map so that each edge returns the same value. -typedef constant_property_map< Edge, int > WeightMap; +using WeightMap = constant_property_map< Edge, int >; // Declare a container and its corresponding property map that // will contain the resulting closeness centralities of each // vertex in the graph. -typedef boost::exterior_vertex_property< Graph, float > ClosenessProperty; -typedef ClosenessProperty::container_type ClosenessContainer; -typedef ClosenessProperty::map_type ClosenessMap; +using ClosenessProperty = boost::exterior_vertex_property< Graph, float >; +using ClosenessContainer = ClosenessProperty::container_type; +using ClosenessMap = ClosenessProperty::map_type; int main(int argc, char* argv[]) { diff --git a/example/scc.cpp b/example/scc.cpp index 94dc7d08a..d53765ef8 100644 --- a/example/scc.cpp +++ b/example/scc.cpp @@ -26,7 +26,7 @@ int main() GraphvizDigraph g; read_graphviz("figs/scc.dot", g); - typedef graph_traits< GraphvizDigraph >::vertex_descriptor vertex_t; + using vertex_t = graph_traits< GraphvizDigraph >::vertex_descriptor; std::map< vertex_t, int > component; strong_components(g, make_assoc_property_map(component)); diff --git a/example/simple_planarity_test.cpp b/example/simple_planarity_test.cpp index cb67452a4..3d345b820 100644 --- a/example/simple_planarity_test.cpp +++ b/example/simple_planarity_test.cpp @@ -17,9 +17,8 @@ int main(int argc, char** argv) using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int > >; graph K_4(4); add_edge(0, 1, K_4); diff --git a/example/sloan_ordering.cpp b/example/sloan_ordering.cpp index f3b98d1ea..0fe43d566 100644 --- a/example/sloan_ordering.cpp +++ b/example/sloan_ordering.cpp @@ -71,16 +71,15 @@ int main(int, char*[]) using namespace std; // Defining the graph type - typedef adjacency_list< setS, vecS, undirectedS, + using Graph = adjacency_list< setS, vecS, undirectedS, property< vertex_color_t, default_color_type, property< vertex_degree_t, int, - property< vertex_priority_t, double > > > > - Graph; + property< vertex_priority_t, double > > > >; - typedef graph_traits< Graph >::vertex_descriptor Vertex; - typedef graph_traits< Graph >::vertices_size_type size_type; + using Vertex = graph_traits< Graph >::vertex_descriptor; + using size_type = graph_traits< Graph >::vertices_size_type; - typedef std::pair< std::size_t, std::size_t > Pair; + using Pair = std::pair< std::size_t, std::size_t >; Pair edges[14] = { Pair(0, 3), // a-d Pair(0, 5), // a-f diff --git a/example/stoer_wagner.cpp b/example/stoer_wagner.cpp index ce5b0e59c..567628351 100644 --- a/example/stoer_wagner.cpp +++ b/example/stoer_wagner.cpp @@ -26,12 +26,12 @@ int main() { using namespace std; - typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, - boost::no_property, boost::property< boost::edge_weight_t, int > > - undirected_graph; - typedef boost::property_map< undirected_graph, boost::edge_weight_t >::type - weight_map_type; - typedef boost::property_traits< weight_map_type >::value_type weight_type; + using undirected_graph + = boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, + boost::no_property, boost::property< boost::edge_weight_t, int > >; + using weight_map_type + = boost::property_map< undirected_graph, boost::edge_weight_t >::type; + using weight_type = boost::property_traits< weight_map_type >::value_type; // define the 16 edges of the graph. {3, 4} means an undirected edge between // vertices 3 and 4. @@ -45,7 +45,7 @@ int main() // construct the graph object. 8 is the number of vertices, which are // numbered from 0 through 7, and 16 is the number of edges. - undirected_graph g(edges, edges + 16, ws, 8, 16); + undirected_graph g(std::begin(edges), std::end(edges), ws, 8, 16); // define a property map, `parities`, that will store a boolean value for // each vertex. Vertices that have the same parity after diff --git a/example/straight_line_drawing.cpp b/example/straight_line_drawing.cpp index b76bb4ab3..a425738a9 100644 --- a/example/straight_line_drawing.cpp +++ b/example/straight_line_drawing.cpp @@ -28,16 +28,15 @@ struct coord_t int main(int argc, char** argv) { - typedef adjacency_list< vecS, vecS, undirectedS, - property< vertex_index_t, int > > - graph; + using graph = adjacency_list< vecS, vecS, undirectedS, + property< vertex_index_t, int > >; // Define the storage type for the planar embedding - typedef std::vector< std::vector< graph_traits< graph >::edge_descriptor > > - embedding_storage_t; - typedef boost::iterator_property_map< embedding_storage_t::iterator, - property_map< graph, vertex_index_t >::type > - embedding_t; + using embedding_storage_t + = std::vector< std::vector< graph_traits< graph >::edge_descriptor > >; + using embedding_t + = boost::iterator_property_map< embedding_storage_t::iterator, + property_map< graph, vertex_index_t >::type >; // Create the graph - a maximal planar graph on 7 vertices. The functions // planar_canonical_ordering and chrobak_payne_straight_line_drawing both @@ -76,11 +75,10 @@ int main(int argc, char** argv) planar_canonical_ordering(g, embedding, std::back_inserter(ordering)); // Set up a property map to hold the mapping from vertices to coord_t's - typedef std::vector< coord_t > straight_line_drawing_storage_t; - typedef boost::iterator_property_map< + using straight_line_drawing_storage_t = std::vector< coord_t >; + using straight_line_drawing_t = boost::iterator_property_map< straight_line_drawing_storage_t::iterator, - property_map< graph, vertex_index_t >::type > - straight_line_drawing_t; + property_map< graph, vertex_index_t >::type >; straight_line_drawing_storage_t straight_line_drawing_storage( num_vertices(g)); diff --git a/example/strong-components.cpp b/example/strong-components.cpp index 4e5d876ba..05a86709e 100644 --- a/example/strong-components.cpp +++ b/example/strong-components.cpp @@ -14,7 +14,7 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, directedS > Graph; + using Graph = adjacency_list< vecS, vecS, directedS >; const int N = 6; Graph G(N); add_edge(0, 1, G); diff --git a/example/strong_components.cpp b/example/strong_components.cpp index 2b1e1b13b..a5d1fcc79 100644 --- a/example/strong_components.cpp +++ b/example/strong_components.cpp @@ -61,8 +61,8 @@ int main(int, char*[]) print_graph(G, name); std::cout << std::endl; - typedef graph_traits< - adjacency_list< vecS, vecS, directedS > >::vertex_descriptor Vertex; + using Vertex = graph_traits< + adjacency_list< vecS, vecS, directedS > >::vertex_descriptor; std::vector< int > component(num_vertices(G)), discover_time(num_vertices(G)); diff --git a/example/subgraph.cpp b/example/subgraph.cpp index 36fa274b3..f01473647 100644 --- a/example/subgraph.cpp +++ b/example/subgraph.cpp @@ -41,9 +41,8 @@ int main(int, char*[]) { using namespace boost; - typedef subgraph< adjacency_list< vecS, vecS, directedS, - property< vertex_color_t, int >, property< edge_index_t, int > > > - Graph; + using Graph = subgraph< adjacency_list< vecS, vecS, directedS, + property< vertex_color_t, int >, property< edge_index_t, int > > >; const int N = 6; Graph G0(N); diff --git a/example/subgraph_properties.cpp b/example/subgraph_properties.cpp index 17d217f8b..91f9fcf18 100644 --- a/example/subgraph_properties.cpp +++ b/example/subgraph_properties.cpp @@ -38,15 +38,13 @@ int main(int, char*[]) { using namespace boost; - // typedef adjacency_list_traits Traits;// Does + // using Traits = adjacency_list_traits;// Does // nothing? - typedef property< vertex_color_t, int, - property< vertex_name_t, std::string > > - VertexProperty; + using VertexProperty = property< vertex_color_t, int, + property< vertex_name_t, std::string > >; - typedef subgraph< adjacency_list< vecS, vecS, directedS, VertexProperty, - property< edge_index_t, int > > > - Graph; + using Graph = subgraph< adjacency_list< vecS, vecS, directedS, + VertexProperty, property< edge_index_t, int > > >; const int N = 6; Graph G0(N); diff --git a/example/tiernan_girth_circumference.cpp b/example/tiernan_girth_circumference.cpp index a2c36d3e5..81ab70ab8 100644 --- a/example/tiernan_girth_circumference.cpp +++ b/example/tiernan_girth_circumference.cpp @@ -16,9 +16,9 @@ using namespace std; using namespace boost; // Declare the graph type and its vertex and edge types. -typedef directed_graph<> Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = directed_graph<>; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; int main(int argc, char* argv[]) { diff --git a/example/tiernan_print_cycles.cpp b/example/tiernan_print_cycles.cpp index e07c53fa1..a0f110236 100644 --- a/example/tiernan_print_cycles.cpp +++ b/example/tiernan_print_cycles.cpp @@ -42,9 +42,9 @@ template < typename OutputStream > struct cycle_printer }; // Declare the graph type and its vertex and edge types. -typedef directed_graph<> Graph; -typedef graph_traits< Graph >::vertex_descriptor Vertex; -typedef graph_traits< Graph >::edge_descriptor Edge; +using Graph = directed_graph<>; +using Vertex = graph_traits< Graph >::vertex_descriptor; +using Edge = graph_traits< Graph >::edge_descriptor; int main(int argc, char* argv[]) { diff --git a/example/topo-sort-file-dep.cpp b/example/topo-sort-file-dep.cpp index 6607e7e93..d70a1d541 100644 --- a/example/topo-sort-file-dep.cpp +++ b/example/topo-sort-file-dep.cpp @@ -24,14 +24,14 @@ std::istream& operator>>(std::istream& in, std::pair< T, T >& p) } } -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - vecS, // Store vertex set in a std::vector - directedS // The file dependency graph is directed - > - file_dep_graph; +using file_dep_graph + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + vecS, // Store vertex set in a std::vector + directedS // The file dependency graph is directed + >; -typedef graph_traits< file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits< file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph >::edge_descriptor; void topo_sort_dfs( const file_dep_graph& g, vertex_t u, vertex_t*& topo_order, int* mark) @@ -57,7 +57,7 @@ void topo_sort(const file_dep_graph& g, vertex_t* topo_order) int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator< std::pair< size_type, size_type > > input_begin( diff --git a/example/topo-sort-file-dep2.cpp b/example/topo-sort-file-dep2.cpp index 68304b3fe..e76e4d6ff 100644 --- a/example/topo-sort-file-dep2.cpp +++ b/example/topo-sort-file-dep2.cpp @@ -24,14 +24,14 @@ std::istream& operator>>(std::istream& in, std::pair< T, T >& p) } } -typedef adjacency_list< listS, // Store out-edges of each vertex in a std::list - vecS, // Store vertex set in a std::vector - directedS // The file dependency graph is directed - > - file_dep_graph; +using file_dep_graph + = adjacency_list< listS, // Store out-edges of each vertex in a std::list + vecS, // Store vertex set in a std::vector + directedS // The file dependency graph is directed + >; -typedef graph_traits< file_dep_graph >::vertex_descriptor vertex_t; -typedef graph_traits< file_dep_graph >::edge_descriptor edge_t; +using vertex_t = graph_traits< file_dep_graph >::vertex_descriptor; +using edge_t = graph_traits< file_dep_graph >::edge_descriptor; template < typename Visitor > void dfs_v1( @@ -99,7 +99,7 @@ void topo_sort(const file_dep_graph& g, vertex_t* topo_order) int main(int argc, const char** argv) { std::ifstream file_in(argc >= 2 ? argv[1] : "makefile-dependencies.dat"); - typedef graph_traits< file_dep_graph >::vertices_size_type size_type; + using size_type = graph_traits< file_dep_graph >::vertices_size_type; size_type n_vertices; file_in >> n_vertices; // read in number of vertices std::istream_iterator< std::pair< size_type, size_type > > input_begin( diff --git a/example/topo-sort-with-leda.cpp b/example/topo-sort-with-leda.cpp index d4120b696..0b2b46eb2 100644 --- a/example/topo-sort-with-leda.cpp +++ b/example/topo-sort-with-leda.cpp @@ -16,9 +16,9 @@ int main() { using namespace boost; - typedef GRAPH< std::string, char > graph_t; + using graph_t = GRAPH< std::string, char >; graph_t leda_g; - typedef graph_traits< graph_t >::vertex_descriptor vertex_t; + using vertex_t = graph_traits< graph_t >::vertex_descriptor; std::vector< vertex_t > vert(7); vert[0] = add_vertex(std::string("pick up kids from school"), leda_g); vert[1] = add_vertex(std::string("buy groceries (and snacks)"), leda_g); diff --git a/example/topo-sort-with-sgb.cpp b/example/topo-sort-with-sgb.cpp index eb43a89f5..a060792a6 100644 --- a/example/topo-sort-with-sgb.cpp +++ b/example/topo-sort-with-sgb.cpp @@ -31,7 +31,7 @@ int main() gb_new_arc(sgb_g->vertices + 4, sgb_g->vertices + 6, 0); gb_new_arc(sgb_g->vertices + 5, sgb_g->vertices + 6, 0); - typedef graph_traits< Graph* >::vertex_descriptor vertex_t; + using vertex_t = graph_traits< Graph* >::vertex_descriptor; std::vector< vertex_t > topo_order; topological_sort(sgb_g, std::back_inserter(topo_order), vertex_index_map(get(vertex_index, sgb_g))); diff --git a/example/topo-sort1.cpp b/example/topo-sort1.cpp index 52b30ffcd..9b5b0dd2c 100644 --- a/example/topo-sort1.cpp +++ b/example/topo-sort1.cpp @@ -19,25 +19,17 @@ int main() = { "pick up kids from school", "buy groceries (and snacks)", "get cash at ATM", "drop off kids at soccer practice", "cook dinner", "pick up kids from soccer", "eat dinner" }; - const int n_tasks = sizeof(tasks) / sizeof(char*); - std::vector< std::list< int > > g(n_tasks); - g[0].push_back(3); - g[1].push_back(3); - g[1].push_back(4); - g[2].push_back(1); - g[3].push_back(5); - g[4].push_back(6); - g[5].push_back(6); + std::vector< std::list< int > > g + = { { 3 }, { 3, 4 }, { 1 }, { 5 }, { 6 }, { 6 }, {} }; std::deque< int > topo_order; topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); - int n = 1; - for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) - std::cout << tasks[*i] << std::endl; + for (auto const& vertex : topo_order) + std::cout << tasks[vertex] << std::endl; return EXIT_SUCCESS; } diff --git a/example/topo-sort2.cpp b/example/topo-sort2.cpp index 97c15e0a8..941abcb46 100644 --- a/example/topo-sort2.cpp +++ b/example/topo-sort2.cpp @@ -35,9 +35,8 @@ int main() topological_sort(g, std::front_inserter(topo_order), vertex_index_map(identity_property_map())); - int n = 1; - for (auto i = topo_order.begin(); i != topo_order.end(); ++i, ++n) - std::cout << tasks[*i] << std::endl; + for (auto const& vertex : topo_order) + std::cout << tasks[vertex] << std::endl; return EXIT_SUCCESS; } diff --git a/example/topo_sort.cpp b/example/topo_sort.cpp index b5ee845ba..8346155fa 100644 --- a/example/topo_sort.cpp +++ b/example/topo_sort.cpp @@ -15,7 +15,7 @@ #include #include -typedef std::pair< std::size_t, std::size_t > Pair; +using Pair = std::pair< std::size_t, std::size_t >; /* Topological sort example @@ -38,25 +38,18 @@ int main(int, char*[]) /* Topological sort will need to color the graph. Here we use an internal decorator, so we "property" the color to the graph. */ - typedef adjacency_list< vecS, vecS, directedS, - property< vertex_color_t, default_color_type > > - Graph; + using Graph = adjacency_list< vecS, vecS, directedS, + property< vertex_color_t, default_color_type > >; - typedef boost::graph_traits< Graph >::vertex_descriptor Vertex; - Pair edges[6] = { Pair(0, 1), Pair(2, 4), Pair(2, 5), Pair(0, 3), + using Vertex = boost::graph_traits< Graph >::vertex_descriptor; + const auto edges = { Pair(0, 1), Pair(2, 4), Pair(2, 5), Pair(0, 3), Pair(1, 4), Pair(4, 3) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - // VC++ can't handle the iterator constructor - Graph G(6); - for (std::size_t j = 0; j < 6; ++j) - add_edge(edges[j].first, edges[j].second, G); -#else - Graph G(edges, edges + 6, 6); -#endif + + Graph G(std::begin(edges), std::end(edges), 6 /* vertices count */); auto id = get(vertex_index, G); - typedef std::vector< Vertex > container; + using container = std::vector< Vertex >; container c; topological_sort(G, std::back_inserter(c)); diff --git a/example/transitive_closure.cpp b/example/transitive_closure.cpp index 1699071e8..4fb8cda68 100644 --- a/example/transitive_closure.cpp +++ b/example/transitive_closure.cpp @@ -17,10 +17,10 @@ int main(int, char*[]) { using namespace boost; - typedef property< vertex_name_t, char > Name; - typedef property< vertex_index_t, std::size_t, Name > Index; - typedef adjacency_list< listS, listS, directedS, Index > graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_t; + using Name = property< vertex_name_t, char >; + using Index = property< vertex_index_t, std::size_t, Name >; + using graph_t = adjacency_list< listS, listS, directedS, Index >; + using vertex_t = graph_traits< graph_t >::vertex_descriptor; graph_t G; std::vector< vertex_t > verts(4); for (int i = 0; i < 4; ++i) diff --git a/example/transpose-example.cpp b/example/transpose-example.cpp index 3f7d8fe10..6f3acd5f3 100644 --- a/example/transpose-example.cpp +++ b/example/transpose-example.cpp @@ -14,9 +14,8 @@ int main() { using namespace boost; - typedef adjacency_list< vecS, vecS, bidirectionalS, - property< vertex_name_t, char > > - graph_t; + using graph_t = adjacency_list< vecS, vecS, bidirectionalS, + property< vertex_name_t, char > >; enum { @@ -36,7 +35,7 @@ int main() for (boost::tie(v, v_end) = vertices(G); v != v_end; ++v, ++name) name_map[*v] = name; - typedef std::pair< int, int > E; + using E = std::pair< int, int >; E edge_array[] = { E(a, c), E(a, d), E(b, a), E(b, d), E(c, f), E(d, c), E(d, e), E(d, f), E(e, b), E(e, g), E(f, e), E(f, g) }; for (int i = 0; i < 12; ++i) diff --git a/example/two_graphs_common_spanning_trees.cpp b/example/two_graphs_common_spanning_trees.cpp index 1b60fe19e..95c161174 100644 --- a/example/two_graphs_common_spanning_trees.cpp +++ b/example/two_graphs_common_spanning_trees.cpp @@ -15,43 +15,35 @@ using namespace std; -typedef boost::adjacency_list< boost::vecS, // OutEdgeList +using Graph = boost::adjacency_list< boost::vecS, // OutEdgeList boost::vecS, // VertexList boost::undirectedS, // Directed boost::no_property, // VertexProperties boost::no_property, // EdgeProperties boost::no_property, // GraphProperties boost::listS // EdgeList - > - Graph; + >; -typedef boost::graph_traits< Graph >::vertex_descriptor vertex_descriptor; +using vertex_descriptor = boost::graph_traits< Graph >::vertex_descriptor; -typedef boost::graph_traits< Graph >::edge_descriptor edge_descriptor; +using edge_descriptor = boost::graph_traits< Graph >::edge_descriptor; -typedef boost::graph_traits< Graph >::vertex_iterator vertex_iterator; +using vertex_iterator = boost::graph_traits< Graph >::vertex_iterator; -typedef boost::graph_traits< Graph >::edge_iterator edge_iterator; +using edge_iterator = boost::graph_traits< Graph >::edge_iterator; int main(int argc, char** argv) { Graph iG, vG; - vector< edge_descriptor > iG_o; - vector< edge_descriptor > vG_o; - - iG_o.push_back(boost::add_edge(0, 1, iG).first); - iG_o.push_back(boost::add_edge(0, 2, iG).first); - iG_o.push_back(boost::add_edge(0, 3, iG).first); - iG_o.push_back(boost::add_edge(0, 4, iG).first); - iG_o.push_back(boost::add_edge(1, 2, iG).first); - iG_o.push_back(boost::add_edge(3, 4, iG).first); - - vG_o.push_back(boost::add_edge(1, 2, vG).first); - vG_o.push_back(boost::add_edge(2, 0, vG).first); - vG_o.push_back(boost::add_edge(2, 3, vG).first); - vG_o.push_back(boost::add_edge(4, 3, vG).first); - vG_o.push_back(boost::add_edge(0, 3, vG).first); - vG_o.push_back(boost::add_edge(0, 4, vG).first); + vector< edge_descriptor > iG_o = { boost::add_edge(0, 1, iG).first, + boost::add_edge(0, 2, iG).first, boost::add_edge(0, 3, iG).first, + boost::add_edge(0, 4, iG).first, boost::add_edge(1, 2, iG).first, + boost::add_edge(3, 4, iG).first }; + + vector< edge_descriptor > vG_o = { boost::add_edge(1, 2, vG).first, + boost::add_edge(2, 0, vG).first, boost::add_edge(2, 3, vG).first, + boost::add_edge(4, 3, vG).first, boost::add_edge(0, 3, vG).first, + boost::add_edge(0, 4, vG).first }; vector< bool > inL(iG_o.size(), false); diff --git a/example/undirected_adjacency_list.cpp b/example/undirected_adjacency_list.cpp index 4836d50e1..4ac04c8a0 100644 --- a/example/undirected_adjacency_list.cpp +++ b/example/undirected_adjacency_list.cpp @@ -38,7 +38,7 @@ template < typename DirectedGraph > void directed_graph_demo() { const int V = 2; DirectedGraph digraph(V); - typedef typename DirectedGraph::edge_property_type Weight; + using Weight = typename DirectedGraph::edge_property_type; auto weight = get(edge_weight, digraph); typename graph_traits< DirectedGraph >::edge_descriptor e1, e2; bool found; @@ -65,7 +65,7 @@ template < typename UndirectedGraph > void undirected_graph_demo2() { const int V = 2; UndirectedGraph undigraph(V); - typedef typename UndirectedGraph::edge_property_type Weight; + using Weight = typename UndirectedGraph::edge_property_type; typename property_map< UndirectedGraph, edge_weight_t >::type weight = get(edge_weight, undigraph); typename graph_traits< UndirectedGraph >::edge_descriptor e1, e2; @@ -96,11 +96,11 @@ template < typename UndirectedGraph > void undirected_graph_demo2() int main() { - typedef property< edge_weight_t, double > Weight; - typedef adjacency_list< vecS, vecS, undirectedS, no_property, Weight > - UndirectedGraph; - typedef adjacency_list< vecS, vecS, directedS, no_property, Weight > - DirectedGraph; + using Weight = property< edge_weight_t, double >; + using UndirectedGraph + = adjacency_list< vecS, vecS, undirectedS, no_property, Weight >; + using DirectedGraph + = adjacency_list< vecS, vecS, directedS, no_property, Weight >; undirected_graph_demo1< UndirectedGraph >(); directed_graph_demo< DirectedGraph >(); undirected_graph_demo2< UndirectedGraph >(); diff --git a/example/undirected_dfs.cpp b/example/undirected_dfs.cpp index 05ce6e7ac..d0a9363bd 100644 --- a/example/undirected_dfs.cpp +++ b/example/undirected_dfs.cpp @@ -42,10 +42,9 @@ struct detect_loops : public boost::dfs_visitor<> int main(int, char*[]) { using namespace boost; - typedef adjacency_list< vecS, vecS, undirectedS, no_property, - property< edge_color_t, default_color_type > > - graph_t; - typedef graph_traits< graph_t >::vertex_descriptor vertex_t; + using graph_t = adjacency_list< vecS, vecS, undirectedS, no_property, + property< edge_color_t, default_color_type > >; + using vertex_t = graph_traits< graph_t >::vertex_descriptor; const std::size_t N = sizeof(name) / sizeof(std::string); graph_t g(N); diff --git a/example/undirected_graph.cpp b/example/undirected_graph.cpp index 3fa2847c1..8ca265465 100644 --- a/example/undirected_graph.cpp +++ b/example/undirected_graph.cpp @@ -10,7 +10,7 @@ #include #include -typedef boost::undirected_graph< boost::no_property > Graph; +using Graph = boost::undirected_graph< boost::no_property >; int main(int, char*[]) { diff --git a/example/vector_as_graph.cpp b/example/vector_as_graph.cpp index f9e785ed3..910ffe793 100644 --- a/example/vector_as_graph.cpp +++ b/example/vector_as_graph.cpp @@ -27,22 +27,18 @@ int main() v, w, x, - y, - N + y }; char name[] = "rstuvwxy"; - typedef std::vector< std::list< int > > Graph; - Graph g(N); - g[r].push_back(v); - g[s].push_back(r); - g[s].push_back(r); - g[s].push_back(w); - g[t].push_back(x); - g[u].push_back(t); - g[w].push_back(t); - g[w].push_back(x); - g[x].push_back(y); - g[y].push_back(u); + using Graph = std::vector< std::list< int > >; + Graph g = { { v }, // r + { r, r, w }, // s + { x }, // t + { t }, // u + {}, // v + { t, x }, // w + { y }, // x + { u } }; // y boost::print_graph(g, name); return 0; } diff --git a/example/vertex-name-property.cpp b/example/vertex-name-property.cpp index 0971334c0..fe4bf4fa0 100644 --- a/example/vertex-name-property.cpp +++ b/example/vertex-name-property.cpp @@ -17,7 +17,7 @@ template < typename Graph, typename VertexNamePropertyMap > void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, VertexNamePropertyMap name_map) { - typedef typename graph_traits< Graph >::vertices_size_type size_type; + using size_type = typename graph_traits< Graph >::vertices_size_type; size_type n_vertices; typename graph_traits< Graph >::vertex_descriptor u; typename property_traits< VertexNamePropertyMap >::value_type name; @@ -39,13 +39,12 @@ void read_graph_file(std::istream& graph_in, std::istream& name_in, Graph& g, int main(int argc, const char** argv) { - typedef adjacency_list< listS, // Store out-edges of each vertex in a - // std::list + using graph_type = adjacency_list< listS, // Store out-edges of each vertex + // in a std::list vecS, // Store vertex set in a std::vector directedS, // The graph is directed property< vertex_name_t, std::string > // Add a vertex property - > - graph_type; + >; graph_type g; // use default constructor to create empty graph const char* dep_file_name @@ -73,9 +72,8 @@ int main(int argc, const char** argv) // Create storage for last modified times std::vector< time_t > last_mod_vec(num_vertices(g)); // Create nickname for the property map type - typedef iterator_property_map< std::vector< time_t >::iterator, - property_map< graph_type, vertex_index_t >::type, time_t, time_t& > - iter_map_t; + using iter_map_t = iterator_property_map< std::vector< time_t >::iterator, + property_map< graph_type, vertex_index_t >::type, time_t, time_t& >; // Create last modified time property map iter_map_t mod_time_map(last_mod_vec.begin(), get(vertex_index, g)); diff --git a/example/vertex_basics.cpp b/example/vertex_basics.cpp index 4cbc0bf3e..ded11e67c 100644 --- a/example/vertex_basics.cpp +++ b/example/vertex_basics.cpp @@ -57,8 +57,8 @@ template < class Graph > struct print_edge { print_edge(Graph& g) : G(g) {} - typedef typename boost::graph_traits< Graph >::edge_descriptor Edge; - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Edge = typename boost::graph_traits< Graph >::edge_descriptor; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; void operator()(Edge e) const { auto id = get(vertex_index, G); @@ -76,7 +76,7 @@ template < class Graph > struct print_index { print_index(Graph& g) : G(g) {} - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; void operator()(Vertex c) const { typename boost::property_map< Graph, vertex_index_t >::type id @@ -89,7 +89,7 @@ template < class Graph > struct print_index template < class Graph > struct exercise_vertex { - typedef typename boost::graph_traits< Graph >::vertex_descriptor Vertex; + using Vertex = typename boost::graph_traits< Graph >::vertex_descriptor; exercise_vertex(Graph& _g) : g(_g) {} @@ -123,9 +123,9 @@ template < class Graph > struct exercise_vertex int main() { - typedef adjacency_list< vecS, vecS, bidirectionalS > MyGraphType; + using MyGraphType = adjacency_list< vecS, vecS, bidirectionalS >; - typedef pair< int, int > Pair; + using Pair = pair< int, int >; Pair edge_array[11] = { Pair(0, 1), Pair(0, 2), Pair(0, 3), Pair(0, 4), Pair(2, 0), Pair(3, 0), Pair(2, 4), Pair(3, 1), Pair(3, 4), Pair(4, 0), Pair(4, 1) }; diff --git a/example/vf2_sub_graph_iso_example.cpp b/example/vf2_sub_graph_iso_example.cpp index 613cb6967..d18bb5a3b 100644 --- a/example/vf2_sub_graph_iso_example.cpp +++ b/example/vf2_sub_graph_iso_example.cpp @@ -13,7 +13,7 @@ using namespace boost; int main() { - typedef adjacency_list< setS, vecS, bidirectionalS > graph_type; + using graph_type = adjacency_list< setS, vecS, bidirectionalS >; // Build graph1 int num_vertices1 = 8; diff --git a/example/vf2_sub_graph_iso_multi_example.cpp b/example/vf2_sub_graph_iso_multi_example.cpp index 235df83dd..240f7abcd 100644 --- a/example/vf2_sub_graph_iso_multi_example.cpp +++ b/example/vf2_sub_graph_iso_multi_example.cpp @@ -12,14 +12,13 @@ using namespace boost; int main() { - typedef property< edge_name_t, char > edge_property; - typedef property< vertex_name_t, char, property< vertex_index_t, int > > - vertex_property; + using edge_property = property< edge_name_t, char >; + using vertex_property + = property< vertex_name_t, char, property< vertex_index_t, int > >; // Using a vecS graphs => the index maps are implicit. - typedef adjacency_list< vecS, vecS, bidirectionalS, vertex_property, - edge_property > - graph_type; + using graph_type = adjacency_list< vecS, vecS, bidirectionalS, + vertex_property, edge_property >; // Build graph1 graph_type graph1; diff --git a/example/visitor.cpp b/example/visitor.cpp index 8620c1165..93012e3d2 100644 --- a/example/visitor.cpp +++ b/example/visitor.cpp @@ -50,8 +50,8 @@ using namespace std; template < class Tag > struct edge_printer : public base_visitor< edge_printer< Tag > > { - typedef Tag event_filter; - edge_printer(std::string edge_t) : m_edge_type(edge_t) {} + using event_filter = Tag; + edge_printer(std::string edge_t) : m_edge_type(edge_t) { } template < class Edge, class Graph > void operator()(Edge e, Graph& G) { std::cout << m_edge_type << ": " << source(e, G) << " --> " @@ -69,19 +69,13 @@ int main(int, char*[]) using namespace boost; - typedef adjacency_list<> Graph; - typedef std::pair< int, int > E; - E edges[] = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1), E(3, 4), - E(4, 0), E(4, 1) }; -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300 - Graph G(5); - for (std::size_t j = 0; j < sizeof(edges) / sizeof(E); ++j) - add_edge(edges[j].first, edges[j].second, G); -#else - Graph G(edges, edges + sizeof(edges) / sizeof(E), 5); -#endif + using Graph = adjacency_list<>; + using E = std::pair< int, int >; + const auto edges = { E(0, 2), E(1, 1), E(1, 3), E(2, 1), E(2, 3), E(3, 1), + E(3, 4), E(4, 0), E(4, 1) }; + Graph G(std::begin(edges), std::end(edges), 5); - typedef boost::graph_traits< Graph >::vertices_size_type size_type; + using size_type = boost::graph_traits< Graph >::vertices_size_type; std::vector< size_type > d(num_vertices(G)); std::vector< size_type > f(num_vertices(G)); diff --git a/example/weighted_matching_example.cpp b/example/weighted_matching_example.cpp index 50fe5d50c..b716e6ef6 100644 --- a/example/weighted_matching_example.cpp +++ b/example/weighted_matching_example.cpp @@ -15,10 +15,10 @@ using namespace boost; -typedef property< edge_weight_t, float, property< edge_index_t, int > > - EdgeProperty; -typedef adjacency_list< vecS, vecS, undirectedS, no_property, EdgeProperty > - my_graph; +using EdgeProperty + = property< edge_weight_t, float, property< edge_index_t, int > >; +using my_graph + = adjacency_list< vecS, vecS, undirectedS, no_property, EdgeProperty >; int main(int argc, const char* argv[]) { diff --git a/example/write_graphviz.cpp b/example/write_graphviz.cpp index c033fcb9f..dadf6b5d7 100644 --- a/example/write_graphviz.cpp +++ b/example/write_graphviz.cpp @@ -37,7 +37,7 @@ const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp", "foo.o", int main(int, char*[]) { - typedef std::pair< int, int > Edge; + using Edge = std::pair< int, int >; Edge used_by[] = { Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h), Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp), Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp), @@ -52,10 +52,9 @@ int main(int, char*[]) using namespace boost; - typedef adjacency_list< vecS, vecS, directedS, + using Graph = adjacency_list< vecS, vecS, directedS, property< vertex_color_t, default_color_type >, - property< edge_weight_t, int > > - Graph; + property< edge_weight_t, int > >; Graph g(used_by, used_by + nedges, weights, N); write_graphviz(std::cout, g, make_label_writer(name)); diff --git a/include/boost/graph/adjacency_matrix.hpp b/include/boost/graph/adjacency_matrix.hpp index a089e1cb9..83c22de50 100644 --- a/include/boost/graph/adjacency_matrix.hpp +++ b/include/boost/graph/adjacency_matrix.hpp @@ -433,7 +433,8 @@ struct adj_matrix_traversal_tag : public virtual adjacency_matrix_tag, public virtual vertex_list_graph_tag, public virtual incidence_graph_tag, public virtual adjacency_graph_tag, - public virtual edge_list_graph_tag + public virtual edge_list_graph_tag, + public virtual bidirectional_graph_tag { }; @@ -826,6 +827,27 @@ typename adjacency_matrix< D, VP, EP, GP, A >::degree_size_type in_degree( return n; } +// O(N) +template < typename VP, typename EP, typename GP, typename A > +typename adjacency_matrix< directedS, VP, EP, GP, A >::degree_size_type +degree( + typename adjacency_matrix< directedS, VP, EP, GP, A >::vertex_descriptor u, + const adjacency_matrix< directedS, VP, EP, GP, A >& g) +{ + return in_degree(u, g) + out_degree(u, g); +} + +// O(N) +template < typename VP, typename EP, typename GP, typename A > +typename adjacency_matrix< undirectedS, VP, EP, GP, A >::degree_size_type +degree( + typename adjacency_matrix< undirectedS, VP, EP, GP, A >::vertex_descriptor + u, + const adjacency_matrix< undirectedS, VP, EP, GP, A >& g) +{ + return out_degree(u, g); +} + //========================================================================= // Functions required by the AdjacencyGraph concept diff --git a/include/boost/graph/dominator_tree.hpp b/include/boost/graph/dominator_tree.hpp index 8a9e7afde..afe741fc3 100644 --- a/include/boost/graph/dominator_tree.hpp +++ b/include/boost/graph/dominator_tree.hpp @@ -62,6 +62,21 @@ namespace detail Tag >(timeMap, v, t); } + // Auxiliary structure of different kinds of predecessors are used to + // calculate the semidominators: ancestor, semidominator, and the ancestor + // with the lowest semidominator (`best`). Placing these predecessors in a + // structure let us organize a "vector of structs" what improves cache + // efficiency. + template < class Graph > + struct vertex_triple + { + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + + Vertex semi { graph_traits< Graph >::null_vertex() }; + Vertex ancestor { graph_traits< Graph >::null_vertex() }; + Vertex best { graph_traits< Graph >::null_vertex() }; + }; + template < class Graph, class IndexMap, class TimeMap, class PredMap, class DomTreePredMap > class dominator_visitor @@ -80,13 +95,9 @@ namespace detail */ dominator_visitor(const Graph& g, const Vertex& entry, const IndexMap& indexMap, DomTreePredMap domTreePredMap) - : semi_(num_vertices(g)) - , ancestor_(num_vertices(g), graph_traits< Graph >::null_vertex()) - , samedom_(ancestor_) - , best_(semi_) - , semiMap_(make_iterator_property_map(semi_.begin(), indexMap)) - , ancestorMap_(make_iterator_property_map(ancestor_.begin(), indexMap)) - , bestMap_(make_iterator_property_map(best_.begin(), indexMap)) + : pred_(num_vertices(g)) + , predMap_(make_iterator_property_map(pred_.begin(), indexMap)) + , samedom_(num_vertices(g), graph_traits< Graph >::null_vertex()) , buckets_(num_vertices(g)) , bucketMap_(make_iterator_property_map(buckets_.begin(), indexMap)) , entry_(entry) @@ -132,18 +143,18 @@ namespace detail if (get(dfnumMap, v) <= get(dfnumMap, n)) s2 = v; else - s2 = get(semiMap_, ancestor_with_lowest_semi_(v, dfnumMap)); + s2 = get(predMap_, ancestor_with_lowest_semi_(v, dfnumMap)) + .semi; if (get(dfnumMap, s2) < get(dfnumMap, s)) s = s2; } - put(semiMap_, n, s); + auto& pred_of_n = get(predMap_, n); + pred_of_n = {s, p, n}; // 2. Calculation of n's dominator is deferred until // the path from s to n has been linked into the forest get(bucketMap_, s).push_back(n); - get(ancestorMap_, n) = p; - get(bestMap_, n) = n; // 3. Now that the path from p to v has been linked into // the spanning forest, these lines calculate the dominator of v, @@ -161,7 +172,7 @@ namespace detail { const Vertex v(*buckItr); const Vertex y(ancestor_with_lowest_semi_(v, dfnumMap)); - if (get(semiMap_, y) == get(semiMap_, v)) + if (get(predMap_, y).semi == get(predMap_, v).semi) put(domTreePredMap_, v, p); else put(samedomMap, v, y); @@ -177,24 +188,32 @@ namespace detail const Vertex ancestor_with_lowest_semi_( const Vertex& v, const TimeMap& dfnumMap) { - const Vertex a(get(ancestorMap_, v)); + const Vertex a(get(predMap_, v).ancestor); + const auto& pred_of_a = get(predMap_, a); + + auto& pred_of_v = get(predMap_, v); - if (get(ancestorMap_, a) != graph_traits< Graph >::null_vertex()) + if (pred_of_a.ancestor != graph_traits< Graph >::null_vertex()) { const Vertex b(ancestor_with_lowest_semi_(a, dfnumMap)); + const auto& pred_of_b = get(predMap_, b); - put(ancestorMap_, v, get(ancestorMap_, a)); + pred_of_v.ancestor = pred_of_a.ancestor; - if (get(dfnumMap, get(semiMap_, b)) - < get(dfnumMap, get(semiMap_, get(bestMap_, v)))) - put(bestMap_, v, b); + if (get(dfnumMap, pred_of_b.semi) + < get(dfnumMap, get(predMap_, pred_of_v.best).semi)) + pred_of_v.best = b; } - return get(bestMap_, v); + return pred_of_v.best; } - std::vector< Vertex > semi_, ancestor_, samedom_, best_; - PredMap semiMap_, ancestorMap_, bestMap_; + std::vector< vertex_triple< Graph > > pred_; + iterator_property_map< typename std::vector< vertex_triple< Graph > >::iterator, + IndexMap > + predMap_; + + std::vector< Vertex > samedom_; std::vector< std::vector< Vertex > > buckets_; iterator_property_map< diff --git a/include/boost/graph/howard_cycle_ratio.hpp b/include/boost/graph/howard_cycle_ratio.hpp index fe6c5bd94..8163e63b3 100644 --- a/include/boost/graph/howard_cycle_ratio.hpp +++ b/include/boost/graph/howard_cycle_ratio.hpp @@ -13,7 +13,6 @@ #include #include -#include #include #include #include @@ -241,14 +240,10 @@ namespace detail typename graph_traits< Graph >::out_edge_iterator oei, oeie; for (boost::tie(vi, vie) = vertices(m_g); vi != vie; ++vi) { - using namespace boost::placeholders; - boost::tie(oei, oeie) = out_edges(*vi, m_g); - typename graph_traits< Graph >::out_edge_iterator mei - = boost::first_max_element(oei, oeie, - boost::bind(m_cmp, - boost::bind(&EdgeWeight1::operator[], m_ew1m, _1), - boost::bind(&EdgeWeight1::operator[], m_ew1m, _2))); + auto mei = boost::first_max_element(oei, oeie, + [this](const auto& first, const auto& second) + { return m_cmp(m_ew1m[first], m_ew1m[second]); }); if (mei == oeie) { if (m_sink == graph_traits< Graph >().null_vertex()) @@ -356,16 +351,17 @@ namespace detail */ float_t policy_mcr() { - using namespace boost::placeholders; - std::fill(m_col_bfs.begin(), m_col_bfs.end(), my_white); color_map_t vcm_ = color_map_t(m_col_bfs.begin(), m_vim); typename graph_traits< Graph >::vertex_iterator uv_itr, vie; boost::tie(uv_itr, vie) = vertices(m_g); float_t mcr = m_bound; while ((uv_itr = std::find_if(uv_itr, vie, - boost::bind(std::equal_to< my_color_type >(), my_white, - boost::bind(&color_map_t::operator[], vcm_, _1)))) + [this, &vcm_](const auto& uv) + { + return std::equal_to< my_color_type >()( + my_white, vcm_[uv]); + })) != vie) /// While there are undiscovered vertices { diff --git a/include/boost/graph/is_straight_line_drawing.hpp b/include/boost/graph/is_straight_line_drawing.hpp index d7701540d..49b522f7f 100644 --- a/include/boost/graph/is_straight_line_drawing.hpp +++ b/include/boost/graph/is_straight_line_drawing.hpp @@ -15,11 +15,7 @@ #include #include #include - -#include -#include -#include - +#include #include #include @@ -28,32 +24,50 @@ namespace boost { -// Overload of make from Boost.Geometry. -template -Geometry make(typename graph_traits::edge_descriptor e, - Graph const &g, - GridPositionMap const &drawing) -{ - auto e_source(source(e, g)); - auto e_target(target(e, g)); - using Float = typename geometry::coordinate_type::type; - return {{numeric_cast(drawing[e_source].x), numeric_cast(drawing[e_source].y)}, - {numeric_cast(drawing[e_target].x), numeric_cast(drawing[e_target].y)}}; + +template +int orientation2d(Int128 ax, Int128 ay, + Int128 bx, Int128 by, + Int128 cx, Int128 cy) { + // If coordinates are in [0, 2^63], this will not overflow. + const Int128 detleft = (bx - ax) * (cy - ay); + const Int128 detright = (by - ay) * (cx - ax); + return detleft > detright ? 1 : (detleft == detright ? 0 : -1); +} + +template +bool between(const Point& a, const Point& b, const Point& c) { + return (b.y == a.y ? + std::min(a.x, b.x) < c.x && c.x < std::max(a.x, b.x) + : std::min(a.y, b.y) < c.y && c.y < std::max(a.y, b.y)); } -// Overload of crosses from Boost.Geometry. +// Crosses in the sense the e and f intersect but are not equal and the +// intersection set is not a shared endpoint. template bool crosses(typename graph_traits::edge_descriptor e, typename graph_traits::edge_descriptor f, Graph const &g, GridPositionMap const &drawing) { - using geometry::crosses; - using geometry::model::linestring; - using geometry::model::d2::point_xy; - using linestring2d = geometry::model::linestring>; - return crosses(make(e, g, drawing), - make(f, g, drawing)); + const auto& p1 = drawing[source(e, g)]; + const auto& p2 = drawing[target(e, g)]; + const auto& q1 = drawing[source(f, g)]; + const auto& q2 = drawing[target(f, g)]; + + using boost::multiprecision::int128_t; + int o1 = orientation2d(p1.x, p1.y, p2.x, p2.y, q1.x, q1.y); + int o2 = orientation2d(p1.x, p1.y, p2.x, p2.y, q2.x, q2.y); + int o3 = orientation2d(q1.x, q1.y, q2.x, q2.y, p1.x, p1.y); + int o4 = orientation2d(q1.x, q1.y, q2.x, q2.y, p2.x, p2.y); + + // X-like crossing of (p1, p2), (q1, q2) + return ((o1 * o2 < 0) && (o3 * o4 < 0)) + // T-like crossing, e.g. q1 in (p1, p2), or partial overlap + || (o1 == 0 && between(p1, p2, q1)) + || (o2 == 0 && between(p1, p2, q2)) + || (o3 == 0 && between(q1, q2, p1)) + || (o4 == 0 && between(q1, q2, p2)); } template < typename Graph, typename GridPositionMap, typename VertexIndexMap > diff --git a/include/boost/graph/isomorphism.hpp b/include/boost/graph/isomorphism.hpp index 5a7d31ddc..a16643a0b 100644 --- a/include/boost/graph/isomorphism.hpp +++ b/include/boost/graph/isomorphism.hpp @@ -91,7 +91,7 @@ namespace detail assert(x_multiplicity_iter != multiplicity->end()); auto y_multiplicity_iter = multiplicity->find(invariant1(y)); assert(y_multiplicity_iter != multiplicity->end()); - return *x_multiplicity_iter < *y_multiplicity_iter; + return x_multiplicity_iter->second < y_multiplicity_iter->second; } Invariant1 invariant1; const InvariantCountMap* multiplicity; diff --git a/include/boost/graph/king_ordering.hpp b/include/boost/graph/king_ordering.hpp index 6a0bd9394..9f4411086 100644 --- a/include/boost/graph/king_ordering.hpp +++ b/include/boost/graph/king_ordering.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -49,8 +48,6 @@ namespace detail template < typename Vertex, typename Graph > void finish_vertex(Vertex, Graph& g) { - using namespace boost::placeholders; - typename graph_traits< Graph >::out_edge_iterator ei, ei_end; Vertex v, w; @@ -61,7 +58,7 @@ namespace detail reverse_iterator rbegin = Qptr->rbegin(); // heap the vertices already there - std::make_heap(rbegin, rend, boost::bind< bool >(comp, _2, _1)); + std::make_heap(rbegin, rend, [this](const auto& first, const auto& second) { return comp(second, first); }); unsigned i = 0; diff --git a/include/boost/graph/transitive_closure.hpp b/include/boost/graph/transitive_closure.hpp index 4d62379c8..bd328efd6 100644 --- a/include/boost/graph/transitive_closure.hpp +++ b/include/boost/graph/transitive_closure.hpp @@ -11,9 +11,8 @@ #include #include // for std::min and std::max -#include +#include //for std::less #include -#include #include #include #include @@ -130,16 +129,16 @@ void transitive_closure(const Graph& g, GraphTC& tc, std::vector< std::vector< cg_vertex > > CG_vec(num_vertices(CG)); for (size_type i = 0; i < num_vertices(CG); ++i) { - using namespace boost::placeholders; - typedef typename boost::graph_traits< CG_t >::adjacency_iterator cg_adj_iter; std::pair< cg_adj_iter, cg_adj_iter > pr = adjacent_vertices(i, CG); CG_vec[i].assign(pr.first, pr.second); std::sort(CG_vec[i].begin(), CG_vec[i].end(), - boost::bind(std::less< cg_vertex >(), - boost::bind(detail::subscript(topo_number), _1), - boost::bind(detail::subscript(topo_number), _2))); + [&topo_number](const auto& cg_0, const auto& cg_1) + { + return std::less< cg_vertex >()( + topo_number[cg_0], topo_number[cg_1]); + }); } std::vector< std::vector< cg_vertex > > chains; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index b2e29dd02..11cfbdaae 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -7,9 +7,12 @@ # Define SGB (stanford graph base top level directory) and # LEDA (also top level directory) at the command line of jam using -s +require-b2 5.0.1 ; +import-search /boost/config/checks ; + import modules ; import path ; -import ../../config/checks/config : requires ; +import config : requires ; path-constant TEST_DIR : . ; @@ -19,6 +22,10 @@ path-constant CYCLE_RATIO_INPUT_FILE : ./cycle_ratio_s382.90.dot ; path-constant METIS_INPUT_FILE : ./weighted_graph.gr ; +path-constant WEIGHTED_MATCHING_INPUT_FILE : ./weighted_matching.dat ; + +project : requirements /boost/graph//boost_graph ; + alias graph_test_regular : # test_graphs will eventually defined a framework for testing the structure # and implementation of graph data structures and adaptors. @@ -73,13 +80,13 @@ alias graph_test_regular : [ run graph.cpp : : : TEST=9 : graph_9 ] [ compile graph_concepts.cpp ] [ run graphviz_test.cpp - ../build//boost_graph : --log_level=all ] + /boost/graph//boost_graph : --log_level=all ] [ run metis_test.cpp : $(METIS_INPUT_FILE) ] [ run gursoy_atun_layout_test.cpp : : : [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ] [ run layout_test.cpp : : : always_show_run_output intel:off [ requires cxx11_noexcept cxx11_rvalue_references sfinae_expr cxx11_auto_declarations cxx11_lambdas cxx11_unified_initialization_syntax cxx11_hdr_tuple cxx11_hdr_initializer_list cxx11_hdr_chrono cxx11_thread_local cxx11_constexpr cxx11_nullptr cxx11_numeric_limits cxx11_decltype cxx11_hdr_array cxx11_hdr_atomic cxx11_hdr_type_traits cxx11_allocator cxx11_explicit_conversion_operators ] ] [ run serialize.cpp - ../../serialization/build//boost_serialization + /boost/serialization//boost_serialization : : : ] [ compile reverse_graph_cc.cpp ] @@ -113,11 +120,11 @@ alias graph_test_regular : [ run cuthill_mckee_ordering.cpp ] [ run king_ordering.cpp ] [ run matching_test.cpp ] - [ run weighted_matching_test.cpp ] + [ run weighted_matching_test.cpp : $(WEIGHTED_MATCHING_INPUT_FILE) ] [ run weighted_matching_test2.cpp ] [ run max_flow_test.cpp ] [ run boykov_kolmogorov_max_flow_test.cpp ] - [ run cycle_ratio_tests.cpp ../build//boost_graph : $(CYCLE_RATIO_INPUT_FILE) ] + [ run cycle_ratio_tests.cpp /boost/graph//boost_graph : $(CYCLE_RATIO_INPUT_FILE) ] [ run basic_planarity_test.cpp ] [ run make_connected_test.cpp ] [ run make_bicon_planar_test.cpp ] @@ -138,14 +145,14 @@ alias graph_test_regular : [ run clustering_coefficient.cpp ] [ run core_numbers_test.cpp ] [ run read_propmap.cpp ] - [ run mcgregor_subgraphs_test.cpp ../build//boost_graph ] + [ run mcgregor_subgraphs_test.cpp /boost/graph//boost_graph ] [ compile grid_graph_cc.cpp ] [ run grid_graph_test.cpp ] [ run incremental_components_test.cpp ] [ run two_graphs_common_spanning_trees_test.cpp ] - [ run random_spanning_tree_test.cpp ../build//boost_graph ] + [ run random_spanning_tree_test.cpp /boost/graph//boost_graph ] [ run random_matching_test.cpp : 1000 1020 ] - [ run graphml_test.cpp ../build//boost_graph : : "graphml_test.xml" ] + [ run graphml_test.cpp /boost/graph//boost_graph : : "graphml_test.xml" ] [ run mas_test.cpp : $(TEST_DIR) ] [ run stoer_wagner_test.cpp : $(TEST_DIR) ] [ compile filtered_graph_properties_dijkstra.cpp ] @@ -171,12 +178,12 @@ alias graph_test_with_filesystem : : alias graph_test_with_filesystem : [ run all_planar_input_files_test.cpp - ../../filesystem/build - ../../system/build + /boost/filesystem//boost_filesystem + /boost/system//boost_system : $(PLANAR_INPUT_FILES) ] [ run parallel_edges_loops_test.cpp - ../../filesystem/build - ../../system/build + /boost/filesystem//boost_filesystem + /boost/system//boost_system : $(PLANAR_INPUT_FILES) ] ; diff --git a/test/adj_matrix_cc.cpp b/test/adj_matrix_cc.cpp index 9457a70c8..68d024ca3 100644 --- a/test/adj_matrix_cc.cpp +++ b/test/adj_matrix_cc.cpp @@ -21,6 +21,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((MutableGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); } @@ -30,6 +31,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((MutableGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); } @@ -44,6 +46,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); BOOST_CONCEPT_ASSERT((VertexMutablePropertyGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((EdgeMutablePropertyGraphConcept< Graph >)); @@ -64,6 +67,7 @@ int main(int, char*[]) BOOST_CONCEPT_ASSERT((EdgeListGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((IncidenceGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((AdjacencyMatrixConcept< Graph >)); BOOST_CONCEPT_ASSERT((VertexMutablePropertyGraphConcept< Graph >)); BOOST_CONCEPT_ASSERT((EdgeMutablePropertyGraphConcept< Graph >)); diff --git a/test/dominator_tree_test.cpp b/test/dominator_tree_test.cpp index 86835cf0f..2b53b9486 100644 --- a/test/dominator_tree_test.cpp +++ b/test/dominator_tree_test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include using namespace std; @@ -24,13 +25,51 @@ struct DominatorCorrectnessTestSet using namespace boost; -typedef adjacency_list< listS, listS, bidirectionalS, - property< vertex_index_t, std::size_t >, no_property > - G; +// a workaround for the C++ standard before C++17, after switching to C++17, +// the method may be just inlined into the run_test() with constexpr if. +namespace detail +{ -int main(int, char*[]) +template < typename Graph > +void index_graph(Graph&, std::true_type /*IsRandomAccessAdjacentList*/) +{ + // nothing to do for already indexed adjacent list +} + +template < typename Graph > +void index_graph(Graph& g, std::false_type /*IsRandomAccessAdjacentList*/) { - typedef DominatorCorrectnessTestSet::edge edge; + using IndexMap = typename property_map< Graph, vertex_index_t >::type; + IndexMap indexMap(get(vertex_index, g)); + typename graph_traits< Graph >::vertex_iterator uItr, uEnd; + int j = 0; + for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr, ++j) + { + put(indexMap, *uItr, j); + } +} + +} // namespace detail + +template < typename OEL, typename VL, typename D, typename VP, typename EP, + typename GP, typename EL > +void index_graph(adjacency_list< OEL, VL, D, VP, EP, GP, EL >& g) +{ + using Traits = adjacency_list_traits< OEL, VL, D, EL >; + ::detail::index_graph( + g, std::integral_constant< bool, Traits::is_rand_access::value > {}); +} + +template < typename D, typename VP, typename EP, typename GP, typename A > +void index_graph(adjacency_matrix&) +{ + // nothing to do for already indexed adjacent matrix +} + +template < typename Graph > +void run_test() +{ + using edge = DominatorCorrectnessTestSet::edge; DominatorCorrectnessTestSet testSet[7]; @@ -217,34 +256,32 @@ int main(int, char*[]) { const int numOfVertices = testSet[i].numOfVertices; - G g(testSet[i].edges.begin(), testSet[i].edges.end(), numOfVertices); + Graph g(testSet[i].edges.begin(), testSet[i].edges.end(), numOfVertices); + + using Vertex = typename graph_traits< Graph >::vertex_descriptor; + using IndexMap = typename property_map< Graph, vertex_index_t >::type; + IndexMap indexMap(get(vertex_index, g)); + using PredMap + = iterator_property_map< typename vector< Vertex >::iterator, IndexMap >; - typedef graph_traits< G >::vertex_descriptor Vertex; - typedef property_map< G, vertex_index_t >::type IndexMap; - typedef iterator_property_map< vector< Vertex >::iterator, IndexMap > - PredMap; + index_graph(g); vector< Vertex > domTreePredVector, domTreePredVector2; - IndexMap indexMap(get(vertex_index, g)); - graph_traits< G >::vertex_iterator uItr, uEnd; - int j = 0; - for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr, ++j) - { - put(indexMap, *uItr, j); - } // Lengauer-Tarjan dominator tree algorithm domTreePredVector = vector< Vertex >( - num_vertices(g), graph_traits< G >::null_vertex()); + num_vertices(g), graph_traits< Graph >::null_vertex()); PredMap domTreePredMap = make_iterator_property_map(domTreePredVector.begin(), indexMap); lengauer_tarjan_dominator_tree(g, vertex(0, g), domTreePredMap); vector< int > idom(num_vertices(g)); + typename graph_traits< Graph >::vertex_iterator uItr, uEnd; for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) { - if (get(domTreePredMap, *uItr) != graph_traits< G >::null_vertex()) + if (get(domTreePredMap, *uItr) + != graph_traits< Graph >::null_vertex()) idom[get(indexMap, *uItr)] = get(indexMap, get(domTreePredMap, *uItr)); else @@ -260,7 +297,7 @@ int main(int, char*[]) // compare results of fast version and slow version of dominator tree domTreePredVector2 = vector< Vertex >( - num_vertices(g), graph_traits< G >::null_vertex()); + num_vertices(g), graph_traits< Graph >::null_vertex()); domTreePredMap = make_iterator_property_map(domTreePredVector2.begin(), indexMap); @@ -269,7 +306,8 @@ int main(int, char*[]) vector< int > idom2(num_vertices(g)); for (boost::tie(uItr, uEnd) = vertices(g); uItr != uEnd; ++uItr) { - if (get(domTreePredMap, *uItr) != graph_traits< G >::null_vertex()) + if (get(domTreePredMap, *uItr) + != graph_traits< Graph >::null_vertex()) idom2[get(indexMap, *uItr)] = get(indexMap, get(domTreePredMap, *uItr)); else @@ -283,6 +321,21 @@ int main(int, char*[]) for (k = 0; k < num_vertices(g); ++k) BOOST_TEST(domTreePredVector[k] == domTreePredVector2[k]); } + cout << endl; +} + +int main(int, char*[]) +{ + using AdjacencyListList = adjacency_list< listS, listS, bidirectionalS, + property< vertex_index_t, std::size_t >, no_property >; + + using AdjacencyListVec = adjacency_list< listS, vecS, bidirectionalS >; + + using AdjacencyMatrix = adjacency_matrix< directedS >; + + run_test< AdjacencyListList >(); + run_test< AdjacencyListVec >(); + run_test< AdjacencyMatrix >(); return boost::report_errors(); } diff --git a/test/github-428-0.dot b/test/github-428-0.dot new file mode 100644 index 000000000..66857641e --- /dev/null +++ b/test/github-428-0.dot @@ -0,0 +1,175 @@ +digraph G { +0; +1; +2; +3; +4; +5; +6; +7; +8; +9; +10; +11; +12; +13; +14; +15; +16; +17; +18; +19; +20; +21; +22; +23; +24; +25; +26; +27; +28; +29; +30; +31; +32; +33; +34; +35; +36; +37; +38; +39; +40; +41; +42; +43; +44; +45; +46; +47; +48; +49; +50; +51; +52; +53; +54; +55; +56; +57; +58; +59; +60; +61; +62; +63; +64; +65; +66; +67; +68; +69; +70; +71; +72; +73; +74; +6->23 ; +0->23 ; +6->24 ; +0->24 ; +6->25 ; +1->25 ; +6->26 ; +1->26 ; +6->27 ; +2->27 ; +6->28 ; +2->28 ; +6->29 ; +3->29 ; +6->30 ; +3->30 ; +6->31 ; +4->31 ; +6->32 ; +4->32 ; +6->33 ; +5->33 ; +6->34 ; +5->34 ; +6->35 ; +0->35 ; +7->36 ; +1->36 ; +8->37 ; +3->37 ; +9->38 ; +3->38 ; +10->39 ; +3->39 ; +11->40 ; +3->40 ; +12->41 ; +3->41 ; +13->42 ; +3->42 ; +17->43 ; +3->43 ; +14->44 ; +3->44 ; +15->45 ; +3->45 ; +16->46 ; +3->46 ; +18->47 ; +3->47 ; +19->48 ; +3->48 ; +20->49 ; +3->49 ; +21->50 ; +3->50 ; +22->51 ; +3->51 ; +35->52 ; +69->52 ; +36->53 ; +70->53 ; +37->54 ; +72->54 ; +38->55 ; +72->55 ; +39->56 ; +72->56 ; +40->57 ; +72->57 ; +41->58 ; +72->58 ; +42->59 ; +72->59 ; +43->60 ; +72->60 ; +44->61 ; +72->61 ; +45->62 ; +72->62 ; +46->63 ; +72->63 ; +47->64 ; +72->64 ; +48->65 ; +72->65 ; +49->66 ; +72->66 ; +50->67 ; +72->67 ; +51->68 ; +72->68 ; +24->69 ; +26->70 ; +28->71 ; +30->72 ; +32->73 ; +34->74 ; +} diff --git a/test/github-428-1.dot b/test/github-428-1.dot new file mode 100644 index 000000000..b002bfe02 --- /dev/null +++ b/test/github-428-1.dot @@ -0,0 +1,175 @@ +digraph G { +0; +1; +2; +3; +4; +5; +6; +7; +8; +9; +10; +11; +12; +13; +14; +15; +16; +17; +18; +19; +20; +21; +22; +23; +24; +25; +26; +27; +28; +29; +30; +31; +32; +33; +34; +35; +36; +37; +38; +39; +40; +41; +42; +43; +44; +45; +46; +47; +48; +49; +50; +51; +52; +53; +54; +55; +56; +57; +58; +59; +60; +61; +62; +63; +64; +65; +66; +67; +68; +69; +70; +71; +72; +73; +74; +6->23 ; +0->23 ; +6->24 ; +0->24 ; +6->25 ; +1->25 ; +6->26 ; +1->26 ; +6->27 ; +2->27 ; +6->28 ; +2->28 ; +6->29 ; +3->29 ; +6->30 ; +3->30 ; +6->31 ; +4->31 ; +6->32 ; +4->32 ; +6->33 ; +5->33 ; +6->34 ; +5->34 ; +6->35 ; +0->35 ; +7->36 ; +1->36 ; +10->37 ; +3->37 ; +11->38 ; +3->38 ; +12->39 ; +3->39 ; +13->40 ; +3->40 ; +17->41 ; +3->41 ; +14->42 ; +3->42 ; +15->43 ; +3->43 ; +16->44 ; +3->44 ; +18->45 ; +3->45 ; +19->46 ; +3->46 ; +20->47 ; +3->47 ; +21->48 ; +3->48 ; +22->49 ; +3->49 ; +8->50 ; +3->50 ; +9->51 ; +3->51 ; +35->52 ; +69->52 ; +36->53 ; +70->53 ; +37->54 ; +72->54 ; +38->55 ; +72->55 ; +39->56 ; +72->56 ; +40->57 ; +72->57 ; +41->58 ; +72->58 ; +42->59 ; +72->59 ; +43->60 ; +72->60 ; +44->61 ; +72->61 ; +45->62 ; +72->62 ; +46->63 ; +72->63 ; +47->64 ; +72->64 ; +48->65 ; +72->65 ; +49->66 ; +72->66 ; +50->67 ; +72->67 ; +51->68 ; +72->68 ; +24->69 ; +26->70 ; +28->71 ; +30->72 ; +32->73 ; +34->74 ; +} diff --git a/test/graph.cpp b/test/graph.cpp index 65c6cf92f..614fb463c 100644 --- a/test/graph.cpp +++ b/test/graph.cpp @@ -70,11 +70,8 @@ bool check_vertex_cleared(Graph& g, Vertex v, ID id) found = ai; break; } -#elif defined(BOOST_NO_CXX98_BINDERS) - found - = std::find_if(ai, aiend, std::bind(cmp, v, std::placeholders::_1)); #else - found = std::find_if(ai, aiend, std::bind1st(cmp, v)); + found = std::find_if(ai, aiend, [&v, &cmp](const auto& el) { return cmp(v, el); }); #endif if (found != aiend) diff --git a/test/isomorphism.cpp b/test/isomorphism.cpp index b5c276a1c..1267b4df9 100644 --- a/test/isomorphism.cpp +++ b/test/isomorphism.cpp @@ -31,6 +31,10 @@ #include #include +#define BOOST_GRAPH_USE_SPIRIT_PARSER +#include +#include + #ifndef BOOST_NO_CXX11_HDR_RANDOM #include typedef std::mt19937 random_generator_type; @@ -404,12 +408,51 @@ void test_colored_isomorphism(int n, double edge_probability) } } +struct VertexProps +{ + std::string node_id; // will store "0", "1", ..., "74" +}; + +using Graph = boost::adjacency_list; +void loadGraphFromDOT(const std::string& filename, Graph& g) +{ + std::ifstream in(filename); + if (!in) + { + throw std::runtime_error("Error: Cannot open file "); + + } + auto node_id_map = boost::get(&VertexProps::node_id, g); + boost::dynamic_properties dp; + dp.property("node_id", node_id_map); + + if (!boost::read_graphviz(in, g, dp)) + { + throw std::runtime_error("Error: Failed to read DOT "); + } +} + + + +void test_github_issue_428() +{ + using Graph = boost::adjacency_list; + Graph g0; + Graph g1; + loadGraphFromDOT("github-428-0.dot", g0); + loadGraphFromDOT("github-428-1.dot", g1); + + const bool iso = boost::isomorphism(g0, g1); + BOOST_TEST(iso); +} + int main(int argc, char* argv[]) { int n = argc < 3 ? 30 : boost::lexical_cast< int >(argv[1]); double edge_prob = argc < 3 ? 0.45 : boost::lexical_cast< double >(argv[2]); test_isomorphism(n, edge_prob); test_colored_isomorphism(n, edge_prob); + test_github_issue_428(); return boost::report_errors(); } diff --git a/test/reverse_graph_cc.cpp b/test/reverse_graph_cc.cpp index 7965f25cc..a4e5c56cd 100644 --- a/test/reverse_graph_cc.cpp +++ b/test/reverse_graph_cc.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -59,5 +60,26 @@ int main(int, char*[]) get_property(gr, graph_name_t()); set_property(gr, graph_name_t(), "foo"); } + // Check matrix + { + typedef adjacency_matrix< directedS, + property< vertex_color_t, int >, property< edge_weight_t, int >, + property< graph_name_t, std::string > > + AdjMatrix; + typedef reverse_graph< AdjMatrix > Graph; + BOOST_CONCEPT_ASSERT((VertexListGraphConcept< Graph >)); + BOOST_CONCEPT_ASSERT((BidirectionalGraphConcept< Graph >)); + typedef graph_traits< Graph >::vertex_descriptor Vertex; + typedef graph_traits< Graph >::edge_descriptor Edge; + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Vertex, vertex_color_t >)); + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Edge, edge_weight_t >)); + BOOST_CONCEPT_ASSERT( + (ReadablePropertyGraphConcept< Graph, Edge, edge_underlying_t >)); + AdjMatrix g(42); + Graph gr(g); + get_property(gr, graph_name_t()); + } return 0; } diff --git a/test/test_graphs.cpp b/test/test_graphs.cpp index 81c489bb5..577d9fff4 100644 --- a/test/test_graphs.cpp +++ b/test/test_graphs.cpp @@ -132,6 +132,8 @@ int main() Graph; BOOST_META_ASSERT(is_directed_graph< Graph >); BOOST_META_ASSERT(!is_multigraph< Graph >); + BOOST_META_ASSERT(is_bidirectional_graph< Graph >); + BOOST_META_ASSERT(is_directed_bidirectional_graph< Graph >); BOOST_META_ASSERT(has_vertex_property< Graph >); BOOST_META_ASSERT(has_bundled_vertex_property< Graph >); BOOST_META_ASSERT(has_edge_property< Graph >); @@ -145,6 +147,8 @@ int main() typedef adjacency_matrix< directedS, VertexBundle, EdgeBundle > Graph; BOOST_META_ASSERT(is_directed_graph< Graph >); BOOST_META_ASSERT(!is_multigraph< Graph >); + BOOST_META_ASSERT(is_bidirectional_graph< Graph >); + BOOST_META_ASSERT(is_directed_bidirectional_graph< Graph >); BOOST_META_ASSERT(has_vertex_property< Graph >); BOOST_META_ASSERT(has_bundled_vertex_property< Graph >); BOOST_META_ASSERT(has_edge_property< Graph >); diff --git a/test/weighted_matching_test.cpp b/test/weighted_matching_test.cpp index 30042c553..57b1f8042 100644 --- a/test/weighted_matching_test.cpp +++ b/test/weighted_matching_test.cpp @@ -136,9 +136,12 @@ Graph make_graph(typename graph_traits< Graph >::vertices_size_type num_v, return g; } -int main(int, char*[]) +int main(int argc, char* argv[]) { - std::ifstream in_file("weighted_matching.dat"); + const char* filename = "weighted_matching.dat"; + if (argc > 1) + filename = argv[1]; + std::ifstream in_file(filename); BOOST_TEST(in_file.good()); std::string line; while (std::getline(in_file, line))