-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataProcess.cpp
42 lines (40 loc) · 951 Bytes
/
DataProcess.cpp
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
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define LD long double
#define PII pair<int, int>
struct Edge
{
int to;
double p;
Edge(int a = 0, double b = 0) : to(a), p(b) {}
};
int main()
{
string fileName, outName;
cin >> fileName;
fileName = "../data/" + fileName;
outName = "../data/processed-" + fileName;
ifstream in(fileName.c_str());
ofstream out(outName.c_str());
int n, m;
in >> n >> m;
out << n << "\t" << m << endl;
vector<PII> E;
unordered_map<int, int> name2id;
int id = 0;
for (int i = 0; i < m; i++)
{
int x, y;
in >> x >> y;
if (name2id.find(x) == name2id.end())
name2id[x] = id, id++;
if (name2id.find(y) == name2id.end())
name2id[y] = id, id++;
x = name2id[x];
y = name2id[y];
E.push_back(PII(x, y));
out << x << "\t" << y << endl;
}
return 0;
}