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.

59 lines
1.2 KiB
C++

2 years ago
#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;
1 month ago
long seed = -1;
2 years ago
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]);
}
1 month ago
else if (arg == "-s") {
i++;
seed = atol(argv[i]);
}
2 years ago
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);
}
1 month ago
vector<vector<Edge>> Sol = graph.findSol(count, k, seed);
2 years ago
graph.printSol(Sol);
return 0;
}