 |
OR-Tools
8.1
|
Go to the documentation of this file.
26 #ifndef OR_TOOLS_GRAPH_PERFECT_MATCHING_H_
27 #define OR_TOOLS_GRAPH_PERFECT_MATCHING_H_
32 #include "absl/strings/str_cat.h"
33 #include "absl/strings/str_join.h"
61 void Reset(
int num_nodes);
103 DCHECK(optimal_solution_found_);
104 return optimal_cost_;
110 DCHECK(optimal_solution_found_);
111 return matches_[node];
114 DCHECK(optimal_solution_found_);
119 std::unique_ptr<BlossomGraph> graph_;
125 bool optimal_solution_found_ =
false;
126 int64 optimal_cost_ = 0;
127 int64 maximum_edge_cost_ = 0;
128 std::vector<int> matches_;
352 int NumMatched()
const {
return nodes_.size() - unmatched_nodes_.size(); }
408 void AppendNodePathToRoot(
NodeIndex n, std::vector<NodeIndex>* path)
const;
421 return root_blossom_node_[edge.tail];
424 return root_blossom_node_[edge.head];
431 return root_blossom_node_[edge.OtherEnd(node)];
448 const std::vector<NodeIndex>& SubNodes(
NodeIndex n);
451 bool is_initialized_ =
false;
466 std::vector<NodeIndex> subnodes_;
472 std::vector<NodeIndex> unmatched_nodes_;
475 std::vector<EdgeIndex> primal_update_edge_queue_;
476 std::vector<EdgeIndex> possible_shrink_;
481 std::vector<Edge*> tmp_all_tops_;
488 int64 num_grows_ = 0;
489 int64 num_augments_ = 0;
490 int64 num_shrinks_ = 0;
491 int64 num_expands_ = 0;
492 int64 num_dual_updates_ = 0;
497 #endif // OR_TOOLS_GRAPH_PERFECT_MATCHING_H_
const Node & GetNode(int n) const
CostValue saved_pseudo_dual
ABSL_MUST_USE_RESULT Status Solve()
CostValue Slack(const Edge &edge) const
std::string NodeDebugString(NodeIndex n) const
int Match(int node) const
DEFINE_INT_TYPE(CostValue, int64)
void DebugCheckNoPossiblePrimalUpdates()
CostValue tree_dual_delta
NodeIndex OtherEnd(NodeIndex n) const
std::string EdgeDebugString(EdgeIndex e) const
void DebugUpdateNodeDual(NodeIndex n, CostValue delta)
std::vector< NodeIndex > saved_blossom
BlossomGraph(int num_nodes)
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
void Expand(NodeIndex to_expand)
void UpdateAllTrees(CostValue delta)
DEFINE_INT_TYPE(EdgeIndex, int)
CostValue ComputeMaxCommonTreeDualDeltaAndResetPrimalEdgeQueue()
void Reset(int num_nodes)
MinCostPerfectMatching(int num_nodes)
bool DebugEdgeIsTightAndExternal(const Edge &edge) const
void AddEdgeWithCost(int tail, int head, int64 cost)
CostValue DualObjective() const
static const EdgeIndex kNoEdgeIndex
ABSL_MUST_USE_RESULT bool Initialize()
Edge(NodeIndex t, NodeIndex h, CostValue c)
bool DebugDualsAreFeasible() const
#define DCHECK(condition)
bool operator>(const Edge &other) const
void SetHeapIndex(int index)
int64 OptimalCost() const
NodeIndex Match(NodeIndex n) const
std::string DebugString() const
void AddEdge(NodeIndex tail, NodeIndex head, CostValue cost)
static const CostValue kMaxCostValue
#define DCHECK_EQ(val1, val2)
void Augment(EdgeIndex e)
DEFINE_INT_TYPE(NodeIndex, int)
const std::vector< int > & Matches() const
bool NodeIsMatched(NodeIndex n) const
CostValue Dual(const Node &node) const
void Grow(EdgeIndex e, NodeIndex tail, NodeIndex head)
static const NodeIndex kNoNodeIndex
const Edge & GetEdge(int e) const
void DisplayStats() const
std::vector< NodeIndex > blossom