-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputFile.h
More file actions
50 lines (44 loc) · 1.37 KB
/
InputFile.h
File metadata and controls
50 lines (44 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include "CGraph.h"
#include "Utils.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace DS;
using namespace std;
class InputFile{
public:
void readInput(string path,CGraph<Place,double>* graph){
ifstream in(path.c_str());
string s,line;
double n;
bool flag = false;
Utils::getWord(in,line);
if( line == "P"){
Utils::getWord(in,line);
int nNodes = stoi(line.c_str());
for(int i=0;i< nNodes;i++){
double x,y;
Utils::getWord(in,line);
x = stod(line.c_str());
Utils::getWord(in,line);
y = stod(line.c_str());
Place oPlace(x,y,i);
graph->insertNode(oPlace);
}
}
Utils::getWord(in,line);
if( line == "Edges"){
Utils::getWord(in,line);
int nEdges = stoi(line.c_str());
for(int i=0;i< nEdges;i++){
int to,from;
Utils::getWord(in,line);
to = stoi(line.c_str());
Utils::getWord(in,line);
from = stoi(line.c_str());
graph->insertEdge(graph->nodes[from],graph->nodes[to],0.0,false);
}
}
}
};