NetOptim 1.2.6
Loading...
Searching...
No Matches
test_cases_boost.hpp
Go to the documentation of this file.
1
13#pragma once
14#include <boost/graph/adjacency_list.hpp>
15#include <boost/graph/graph_traits.hpp>
16#include <py2cpp/nx2bgl.hpp>
17#include <utility> // for std::pair
18
20using graph_t = boost::adjacency_list<
21 boost::listS, boost::vecS, boost::directedS, boost::no_property,
22 boost::property<boost::edge_weight_t, int, boost::property<boost::edge_index_t, int>>>;
24using Vertex = boost::graph_traits<graph_t>::vertex_descriptor;
26using Edge_it = boost::graph_traits<graph_t>::edge_iterator;
27
39template <typename Mapping> inline auto create_test_case1(const Mapping& weights)
40 -> py::GraphAdaptor<graph_t> {
41 using edge_t = std::pair<int, int>;
42 const auto num_nodes = 5;
43 enum nodes { A, B, C, D, E };
44 static edge_t edge_array[]
45 = {edge_t{A, B}, edge_t{B, C}, edge_t{C, D}, edge_t{D, E}, edge_t{E, A}};
46 // int weights[] = {-5, 1, 1, 1, 1};
47 int num_arcs = sizeof(edge_array) / sizeof(edge_t);
48 auto g = graph_t(edge_array, edge_array + num_arcs, weights, num_nodes);
49 return py::GraphAdaptor<graph_t>{std::move(g)};
50}
51
69template <typename Mapping> inline auto create_test_case_timing(const Mapping& weights)
70 -> py::GraphAdaptor<graph_t> {
71 using edge_t = std::pair<int, int>;
72 constexpr auto num_nodes = 3;
73 enum nodes { A, B, C };
74 static edge_t edge_array[] = {edge_t{A, B}, edge_t{B, A}, edge_t{B, C}, edge_t{C, B},
75 edge_t{B, C}, edge_t{C, B}, edge_t{C, A}, edge_t{A, C}};
76 // int weights[] = {7, 0, 3, 1, 6, 4, 2, 5};
77 constexpr int num_arcs = sizeof(edge_array) / sizeof(edge_t);
78 auto g = graph_t(edge_array, edge_array + num_arcs, weights, num_nodes);
79 return py::GraphAdaptor<graph_t>{std::move(g)};
80}
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
typename boost::graph_traits< graph_t >::edge_iterator edge_t
Type alias for edge iterator.
Definition test_cases2_boost.hpp:39
typename boost::graph_traits< graph_t >::vertex_descriptor Vertex
Type alias for vertex descriptor.
Definition test_cases2_boost.hpp:37
boost::graph_traits< graph_t >::edge_iterator Edge_it
Type alias for edge iterator.
Definition test_cases_boost.hpp:26
auto create_test_case1(const Mapping &weights) -> py::GraphAdaptor< graph_t >
Create a simple 5-node cycle test graph.
Definition test_cases_boost.hpp:39
boost::adjacency_list< boost::listS, boost::vecS, boost::directedS, boost::no_property, boost::property< boost::edge_weight_t, int, boost::property< boost::edge_index_t, int > > > graph_t
Type alias for Boost adjacency list with edge weights and indices.
Definition test_cases_boost.hpp:22
auto create_test_case_timing(const Mapping &weights) -> py::GraphAdaptor< graph_t >
Create a 3-node timing test graph with parallel edges.
Definition test_cases_boost.hpp:69