You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB
C++

#include <sys/stat.h>
#include "populateGraph.cpp"
using namespace std;
#define ERR(msg) {fprintf(stderr, "%s\n", msg); exit(2);}
int main(int argc,char const *argv[]) {
int k = 5;
int count = 1;
vector<string> Files;
// configurazione opzioni
for (int i = 1; i < argc; i++) {
string arg(argv[i]);
if (arg == "-c") {
i++;
count = atoi(argv[i]);
}
else if (arg == "-k") {
i++;
k = atoi(argv[i]);
}
else {
Files.push_back(arg);
}
}
UndirectedWeightedGraph graph;
for (string File : Files) {
ifstream s(File);
if (!s) ERR("errore di apertura del file")
stringstream buffer;
buffer << s.rdbuf();
//parsing del file
vector<phrase> phrases = parseFile(buffer.str());
//popolazione del grafo
populateGraph(&graph, phrases);
}
vector<vector<Edge>> Sol = graph.findSol(count, k);
graph.printSol(Sol);
return 0;
}