26 #ifndef OR_TOOLS_GRAPH_PERFECT_MATCHING_H_ 27 #define OR_TOOLS_GRAPH_PERFECT_MATCHING_H_ 33 #include "absl/base/attributes.h" 34 #include "absl/strings/str_cat.h" 35 #include "absl/strings/str_join.h" 63 void Reset(
int num_nodes);
105 DCHECK(optimal_solution_found_);
106 return optimal_cost_;
112 DCHECK(optimal_solution_found_);
113 return matches_[node];
116 DCHECK(optimal_solution_found_);
121 std::unique_ptr<BlossomGraph> graph_;
127 bool optimal_solution_found_ =
false;
128 int64_t optimal_cost_ = 0;
129 int64_t maximum_edge_cost_ = 0;
130 std::vector<int> matches_;
410 void AppendNodePathToRoot(
NodeIndex n, std::vector<NodeIndex>* path)
const;
423 return root_blossom_node_[edge.tail];
426 return root_blossom_node_[edge.head];
433 return root_blossom_node_[edge.OtherEnd(node)];
450 const std::vector<NodeIndex>& SubNodes(
NodeIndex n);
453 bool is_initialized_ =
false;
468 std::vector<NodeIndex> subnodes_;
474 std::vector<NodeIndex> unmatched_nodes_;
477 std::vector<EdgeIndex> primal_update_edge_queue_;
478 std::vector<EdgeIndex> possible_shrink_;
483 std::vector<Edge*> tmp_all_tops_;
490 int64_t num_grows_ = 0;
491 int64_t num_augments_ = 0;
492 int64_t num_shrinks_ = 0;
493 int64_t num_expands_ = 0;
494 int64_t num_dual_updates_ = 0;
499 #endif // OR_TOOLS_GRAPH_PERFECT_MATCHING_H_
NodeIndex Match(NodeIndex n) const
const Edge & GetEdge(int e) const
std::vector< NodeIndex > saved_blossom
int Match(int node) const
bool operator>(const Edge &other) const
CostValue saved_pseudo_dual
CostValue Slack(const Edge &edge) const
CostValue ComputeMaxCommonTreeDualDeltaAndResetPrimalEdgeQueue()
void DebugCheckNoPossiblePrimalUpdates()
void AddEdge(NodeIndex tail, NodeIndex head, CostValue cost)
void UpdateAllTrees(CostValue delta)
std::string EdgeDebugString(EdgeIndex e) const
void DebugUpdateNodeDual(NodeIndex n, CostValue delta)
static const EdgeIndex kNoEdgeIndex
std::vector< NodeIndex > blossom
NodeIndex OtherEnd(NodeIndex n) const
CostValue Dual(const Node &node) const
std::string DebugString() const
bool DebugEdgeIsTightAndExternal(const Edge &edge) const
Edge(NodeIndex t, NodeIndex h, CostValue c)
int64_t OptimalCost() const
void AddEdgeWithCost(int tail, int head, int64_t cost)
ABSL_MUST_USE_RESULT Status Solve()
ABSL_MUST_USE_RESULT bool Initialize()
void Grow(EdgeIndex e, NodeIndex tail, NodeIndex head)
std::string NodeDebugString(NodeIndex n) const
DEFINE_INT_TYPE(NodeIndex, int)
void SetHeapIndex(int index)
CostValue tree_dual_delta
#define DCHECK(condition)
static const NodeIndex kNoNodeIndex
bool DebugDualsAreFeasible() const
#define DCHECK_EQ(val1, val2)
void Augment(EdgeIndex e)
const Node & GetNode(int n) const
BlossomGraph(int num_nodes)
Collection of objects used to extend the Constraint Solver library.
const std::vector< int > & Matches() const
bool NodeIsMatched(NodeIndex n) const
static const CostValue kMaxCostValue
void Expand(NodeIndex to_expand)
void DisplayStats() const
MinCostPerfectMatching(int num_nodes)
void Reset(int num_nodes)
CostValue DualObjective() const