NetOptim 1.2.6
Loading...
Searching...
No Matches
test_cases2_boost.hpp
Go to the documentation of this file.
1
14#pragma once
15
16#include <boost/graph/adjacency_list.hpp>
17#include <boost/graph/graph_traits.hpp>
18#include <boost/graph/properties.hpp>
19#include <boost/property_map/property_map.hpp>
20#include <py2cpp/nx2bgl.hpp>
21#include <utility> // for std::pair
22
23namespace boost {
24
26 enum edge_id_tag_t { id_tag }; // a unique #
29
30} // namespace boost
31
34 = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, boost::no_property,
35 boost::property<boost::edge_id_tag_t, size_t>>;
37using Vertex = typename boost::graph_traits<graph_t>::vertex_descriptor;
39using edge_t = typename boost::graph_traits<graph_t>::edge_iterator;
40
55template <typename Mapping> inline auto create_test_case1(const Mapping& weights)
56 -> py::GraphAdaptor<graph_t> {
57 using edge_t = std::pair<int, int>;
58 const auto num_nodes = 5;
59 enum nodes { A, B, C, D, E };
60 static edge_t edge_array[]
61 = {edge_t{A, B}, edge_t{B, C}, edge_t{C, D}, edge_t{D, E}, edge_t{E, A}};
62 // int weights[] = {-5, 1, 1, 1, 1};
63 int num_arcs = sizeof(edge_array) / sizeof(edge_t);
64 auto g = graph_t(edge_array, edge_array + num_arcs, weights, num_nodes);
65 return py::GraphAdaptor<graph_t>{std::move(g)};
66}
67
83template <typename Mapping> inline auto create_test_case_timing(const Mapping& weights)
84 -> py::GraphAdaptor<graph_t> {
85 using edge_t = std::pair<int, int>;
86 constexpr auto num_nodes = 3;
87 enum nodes { A, B, C };
88 static edge_t edge_array[] = {edge_t{A, B}, edge_t{B, A}, edge_t{B, C}, edge_t{C, B},
89 edge_t{B, C}, edge_t{C, B}, edge_t{C, A}, edge_t{A, C}};
90 // int weights[] = {7, 0, 3, 1, 6, 4, 2, 5};
91 constexpr int num_arcs = sizeof(edge_array) / sizeof(edge_t);
92 auto g = graph_t(edge_array, edge_array + num_arcs, weights, num_nodes);
93 return py::GraphAdaptor<graph_t>{std::move(g)};
94}
Definition test_cases2_boost.hpp:23
BOOST_INSTALL_PROPERTY(edge, id_tag)
Install the custom edge property.
edge_id_tag_t
Custom edge tag for storing unique edge identifiers.
Definition test_cases2_boost.hpp:26
@ id_tag
Definition test_cases2_boost.hpp:26
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, boost::no_property, boost::property< boost::edge_id_tag_t, size_t > > graph_t
Type alias for Boost adjacency list with custom edge ID properties.
Definition test_cases2_boost.hpp:35
auto create_test_case1(const Mapping &weights) -> py::GraphAdaptor< graph_t >
Create a simple 5-node cycle test graph with edge IDs.
Definition test_cases2_boost.hpp:55
typename boost::graph_traits< graph_t >::edge_iterator edge_t
Type alias for edge iterator.
Definition test_cases2_boost.hpp:39
auto create_test_case_timing(const Mapping &weights) -> py::GraphAdaptor< graph_t >
Create a 3-node timing test graph with parallel edges and edge IDs.
Definition test_cases2_boost.hpp:83
typename boost::graph_traits< graph_t >::vertex_descriptor Vertex
Type alias for vertex descriptor.
Definition test_cases2_boost.hpp:37