Code for ReductionMatrix Class (PDF)
Document Details
Uploaded by WellEducatedBoolean
Tags
Summary
This C++ code implements a ReductionMatrix class, intended for use with graph algorithms. It deals with reducing matrices, calculating reduction costs, and printing the reduced matrix. The code includes error handling and potentially uses random numbers.
Full Transcript
\#include \#include "ReductionMatrix.h" using namespace std; ReductionMatrix::ReductionMatrix(vector\ matrix) : matrix\_(move(matrix)), reduction\_cost\_(0) {} void ReductionMatrix::reduceMatrix() { reduction\_cost\_ = reduceRows() + reduceColumns(); } int ReductionMatrix::getReductionCost() con...
\#include \#include "ReductionMatrix.h" using namespace std; ReductionMatrix::ReductionMatrix(vector\ matrix) : matrix\_(move(matrix)), reduction\_cost\_(0) {} void ReductionMatrix::reduceMatrix() { reduction\_cost\_ = reduceRows() + reduceColumns(); } int ReductionMatrix::getReductionCost() const { return reduction\_cost\_; } void ReductionMatrix::printMatrix() const { for (const auto& row : matrix\_) { for (const auto& val : row) { if (val == std::numeric\_limits::max()) cout \