tesseract v5.3.3.20231005
testing::internal::MaxBipartiteMatchState Class Reference

Public Member Functions

 MaxBipartiteMatchState (const MatchMatrix &graph)
 
ElementMatcherPairs Compute ()
 

Detailed Description

Definition at line 121 of file gmock-matchers.cc.

Constructor & Destructor Documentation

◆ MaxBipartiteMatchState()

testing::internal::MaxBipartiteMatchState::MaxBipartiteMatchState ( const MatchMatrix &  graph)
inlineexplicit

Definition at line 123 of file gmock-matchers.cc.

124 : graph_(&graph),
125 left_(graph_->LhsSize(), kUnused),
126 right_(graph_->RhsSize(), kUnused) {}

Member Function Documentation

◆ Compute()

ElementMatcherPairs testing::internal::MaxBipartiteMatchState::Compute ( )
inline

Definition at line 129 of file gmock-matchers.cc.

129 {
130 // 'seen' is used for path finding { 0: unseen, 1: seen }.
131 ::std::vector<char> seen;
132 // Searches the residual flow graph for a path from each left node to
133 // the sink in the residual flow graph, and if one is found, add flow
134 // to the graph. It's okay to search through the left nodes once. The
135 // edge from the implicit source node to each previously-visited left
136 // node will have flow if that left node has any path to the sink
137 // whatsoever. Subsequent augmentations can only add flow to the
138 // network, and cannot take away that previous flow unit from the source.
139 // Since the source-to-left edge can only carry one flow unit (or,
140 // each element can be matched to only one matcher), there is no need
141 // to visit the left nodes more than once looking for augmented paths.
142 // The flow is known to be possible or impossible by looking at the
143 // node once.
144 for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {
145 // Reset the path-marking vector and try to find a path from
146 // source to sink starting at the left_[ilhs] node.
147 GTEST_CHECK_(left_[ilhs] == kUnused)
148 << "ilhs: " << ilhs << ", left_[ilhs]: " << left_[ilhs];
149 // 'seen' initialized to 'graph_->RhsSize()' copies of 0.
150 seen.assign(graph_->RhsSize(), 0);
151 TryAugment(ilhs, &seen);
152 }
153 ElementMatcherPairs result;
154 for (size_t ilhs = 0; ilhs < left_.size(); ++ilhs) {
155 size_t irhs = left_[ilhs];
156 if (irhs == kUnused) continue;
157 result.push_back(ElementMatcherPair(ilhs, irhs));
158 }
159 return result;
160 }
#define GTEST_CHECK_(condition)
Definition: gtest-port.h:1008

The documentation for this class was generated from the following file: