Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::MaxBipartiteMatchState Class Reference

Public Member Functions

 MaxBipartiteMatchState (const MatchMatrix &graph)
 
ElementMatcherPairs Compute ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ MaxBipartiteMatchState()

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

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

236 : graph_(&graph),
237 left_(graph_->LhsSize(), kUnused),
238 right_(graph_->RhsSize(), kUnused) {}

Member Function Documentation

◆ Compute()

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

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

241 {
242 // 'seen' is used for path finding { 0: unseen, 1: seen }.
243 ::std::vector<char> seen;
244 // Searches the residual flow graph for a path from each left node to
245 // the sink in the residual flow graph, and if one is found, add flow
246 // to the graph. It's okay to search through the left nodes once. The
247 // edge from the implicit source node to each previously-visited left
248 // node will have flow if that left node has any path to the sink
249 // whatsoever. Subsequent augmentations can only add flow to the
250 // network, and cannot take away that previous flow unit from the source.
251 // Since the source-to-left edge can only carry one flow unit (or,
252 // each element can be matched to only one matcher), there is no need
253 // to visit the left nodes more than once looking for augmented paths.
254 // The flow is known to be possible or impossible by looking at the
255 // node once.
256 for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {
257 // Reset the path-marking vector and try to find a path from
258 // source to sink starting at the left_[ilhs] node.
259 GTEST_CHECK_(left_[ilhs] == kUnused)
260 << "ilhs: " << ilhs << ", left_[ilhs]: " << left_[ilhs];
261 // 'seen' initialized to 'graph_->RhsSize()' copies of 0.
262 seen.assign(graph_->RhsSize(), 0);
263 TryAugment(ilhs, &seen);
264 }
265 ElementMatcherPairs result;
266 for (size_t ilhs = 0; ilhs < left_.size(); ++ilhs) {
267 size_t irhs = left_[ilhs];
268 if (irhs == kUnused) continue;
269 result.push_back(ElementMatcherPair(ilhs, irhs));
270 }
271 return result;
272 }
#define GTEST_CHECK_(condition)
::std::vector< ElementMatcherPair > ElementMatcherPairs
::std::pair< size_t, size_t > ElementMatcherPair
Here is the call graph for this function:
Here is the caller graph for this function:

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