src/tpp.cpp
/*
 * Loads explicitly given edge weights matrix
 */
Loads explicitly given edge weights matrix
Loads explicitly given edge weights matrix
vector<vector<int>> read_edge_weights(ifstream &file, size_t dimension,
                                      EdgeWeightFormat edge_weight_format) {
    vector<vector<int>> edge_weights;
    LOG_SCOPE_F(INFO, "read_edge_weights");
    edge_weights.resize(dimension);
    if (edge_weight_format != EdgeWeightFormat::UPPER_ROW) {
        LOG_F(ERROR, "Unsupported edge weight format");
        abort();
    }
    for (auto i = 1u; i < dimension; ++i) {
        string line;
        if (!getline(file, line, '\n')) {
            LOG_F(ERROR, "Too few lines in offer section");
            abort();
        }
        auto &weights = edge_weights.at(i - 1u);
        weights.resize(dimension);
        auto iss = istringstream(line);
        for (auto j = i; j < dimension; ++j) {
            iss >> weights.at(j);
        }
    }
    edge_weights.at(dimension-1).resize(dimension);
    for (auto i = 0u; i < dimension; ++i) {
        for (auto j = i + 1; j < dimension; ++j) {
            edge_weights.at(j).at(i) = edge_weights.at(i).at(j);
        }
    }
    return edge_weights;
}
vector < vector < int > > read_edge_weights ( ifstream & file , size_t dimension , EdgeWeightFormat edge_weight_format ) { vector < vector < int > > edge_weights ; LOG_SCOPE_F ( INFO , " " ) ; edge_weights . resize ( dimension ) ; if ( edge_weight_format != EdgeWeightFormat :: UPPER_ROW ) { LOG_F ( ERROR , " " ) ; abort ( ) ; } for ( auto i = 1u ; i < dimension ; ++ i ) { string line ; if ( ! getline ( file , line , ' \n ' ) ) { LOG_F ( ERROR , " " ) ; abort ( ) ; } auto & weights = edge_weights . at ( i - 1u ) ; weights . resize ( dimension ) ; auto iss = istringstream ( line ) ; for ( auto j = i ; j < dimension ; ++ j ) { iss >> weights . at ( j ) ; } } edge_weights . at ( dimension - 1 ) . resize ( dimension ) ; for ( auto i = 0u ; i < dimension ; ++ i ) { for ( auto j = i + 1 ; j < dimension ; ++ j ) { edge_weights . at ( j ) . at ( i ) = edge_weights . at ( i ) . at ( j ) ; } } return edge_weights ; }
Loads explicitly given edge weights matrix
Loads explicitly given edge weights matrix
// Read upper half of the weights section // Fill in the lower left half