16#include <py2cpp/dict.hpp>
17#include <py2cpp/set.hpp>
35template <
typename MakeViolator,
typename WeightMap,
typename SolutionSet>
37 -> std::pair<SolutionSet, typename WeightMap::mapped_type> {
39 using NodeType =
typename SolutionSet::value_type;
55 auto min_vtx = *std::min_element(
57 [&](
const auto&
v1,
const auto&
v2) { return gap[v1] < gap[v2]; });
111template <
typename Graph,
typename WeightMap,
typename CoverSet>
113 -> std::pair<CoverSet, typename WeightMap::mapped_type>;
118template <
typename Graph,
typename WeightMap>
150 Node parent, Node
child) -> std::deque<Node>;
164template <
typename Graph,
typename CoverSet>
166 -> std::vector<std::tuple<py::dict<typename Graph::node_t, BFSInfo<typename Graph::node_t>>,
167 typename Graph::node_t,
typename Graph::node_t>>;
180template <
typename Graph,
typename WeightMap,
typename CoverSet>
182 -> std::pair<CoverSet, typename WeightMap::mapped_type> {
183 using node_t =
typename Graph::node_t;
188 return [&
ugraph, &
coverset]() -> std::optional<std::vector<node_t>> {
190 if (
cycles.empty())
return std::nullopt;
203template <
typename Graph,
typename WeightMap>
221template <
typename Graph,
typename WeightMap,
typename CoverSet>
223 -> std::pair<CoverSet, typename WeightMap::mapped_type>;
228template <
typename Graph,
typename WeightMap>
Read-only map of maps of maps (view into a dict-of-dict-of-dict structure)
Definition coreviews.hpp:109
AdjacencyView(Atlas &d)
Construct an AdjacencyView from an Atlas container.
Definition coreviews.hpp:115
auto begin() const
Get iterator to the beginning of the view.
Definition coreviews.hpp:55
auto end() const
Get iterator to the end of the view.
Definition coreviews.hpp:61
auto pd_cover(MakeViolator make_violator, WeightMap &weight, SolutionSet &soln) -> std::pair< SolutionSet, typename WeightMap::mapped_type >
Implements a primal-dual approximation algorithm for covering problems.
Definition cover.hpp:36
auto generic_bfs_cycle(const Graph &ugraph, const CoverSet &coverset) -> std::vector< std::tuple< py::dict< typename Graph::node_t, BFSInfo< typename Graph::node_t > >, typename Graph::node_t, typename Graph::node_t > >
Generic BFS cycle detection.
auto min_vertex_cover(const Graph &ugraph, WeightMap &weight, CoverSet &coverset) -> std::pair< CoverSet, typename WeightMap::mapped_type >
Performs minimum weighted vertex cover using primal-dual approximation.
auto min_cycle_cover(const Graph &ugraph, WeightMap &weight, CoverSet &coverset) -> std::pair< CoverSet, typename WeightMap::mapped_type >
Performs minimum cycle cover using primal-dual approximation.
Definition cover.hpp:181
auto min_odd_cycle_cover(const Graph &ugraph, WeightMap &weight, CoverSet &coverset) -> std::pair< CoverSet, typename WeightMap::mapped_type >
Performs minimum odd cycle cover using primal-dual approximation.
auto construct_cycle(const py::dict< Node, BFSInfo< Node > > &info, Node parent, Node child) -> std::deque< Node >
Constructs a cycle from BFS information.
Information structure for BFS traversal.
Definition cover.hpp:128
Node parent
Definition cover.hpp:129
BFSInfo & operator=(const BFSInfo &)=default
BFSInfo & operator=(BFSInfo &&)=default
int depth
Definition cover.hpp:130
BFSInfo(const BFSInfo &)=default
BFSInfo(BFSInfo &&)=default
BFSInfo(Node p, int d)
Definition cover.hpp:132