Skip to content
Snippets Groups Projects
Commit a8fb8e4d authored by Lukas Garbas's avatar Lukas Garbas
Browse files

deleted old files

parent b9ddda3a
No related merge requests found
#include <gp-bnb/MetisReader.hpp>
#include <stdexcept>
std::vector<unsigned int> parseLine(std::string& line) {
std::vector<unsigned int> adjacencies;
std::stringstream iss( line );
int node;
while ( iss >> node ) {
adjacencies.push_back( node );
}
return adjacencies;
}
graph MetisReader::read(std::string& path) {
std::ifstream graphFile(path);
std::pair<int, int> header;
std::vector<std::vector<unsigned int>> adjacencies;
int edgeCounter = 0;
std::string line = "";
if (std::getline(graphFile, line)) {
// ignore comment lines
while (line[0] == '%')
std::getline(graphFile, line);
// read the header line
std::vector<unsigned int> firstLine = parseLine(line);
header = std::make_pair(firstLine[0], firstLine[1]);
adjacencies.reserve(header.first);
std::cout << "Reading graph in Metis format ";
std::cout << "(n = " << header.first << ", m = " << header.second << ")" << std::endl;
while (getline(graphFile, line)) {
// ignore comment lines after the header
if (line[0] != '%') {
adjacencies.push_back(parseLine(line));
edgeCounter += adjacencies.back().size();
}
}
}
if ( edgeCounter / 2 != header.second )
puts("Reader Error: incorrect number of edges");
if ( adjacencies.size() != (unsigned int) header.first )
puts("Reader Error: incorrect number of nodes");
graph g = graph(adjacencies);
return g;
}
\ No newline at end of file
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <gp-bnb/graph.hpp>
#ifndef METISREADER_H_
#define METISREADER_H_
/** Reader for the METIS file format **/
class MetisReader {
public:
MetisReader() = default;
graph read(std::string& path);
};
#endif
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment