-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
74 lines (62 loc) · 2.45 KB
/
main.cpp
File metadata and controls
74 lines (62 loc) · 2.45 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
Created by this sarradeiros:
sarradation boy nº 1:
Emmanuel Gustavo Rinaldi Perotto - 15/0124163
sarradation boy nº 2:
Lucas da Silva Moutinho - 15/0015747
Thanks to our mothers that were there to put us in the world. We love You S2!!
*/
#include <fstream>
#include "graph.h"
#include "utils.h"
using namespace std;
// Function: main
// the main software function
// It:
// - reads graph files with different vertices (10, 100, 10000, 100000)
// - creates 4 graphs (with 10, 100, 10000 and 100000 vertices) with its edges
// - executes the DFS topological sort algorithm and the Kahn Topological sort algorithm in each graph
// - stores the time(seconds) vs node info in the results folder
// - opens the graphic visualization with gnuplot
int main()
{
int counter = 0;
int nVertices, originVertex, destinyVertex;
vector<string> files = {"graph-files/top_small.txt",
"graph-files/top_med.txt",
"graph-files/top_large.txt",
"graph-files/top_huge.txt"};
vector<int> noVertices = {10,
100,
10000,
100000};
ofstream dfsDataFile("results/dfs-data.txt");
ofstream kahnDataFile("results/kahn-data.txt");
for (string &fileName : files)
{
ifstream graphFile;
graphFile.open(fileName);
graphFile >> nVertices;
Graph graph(nVertices);
Graph graph2(nVertices);
while (!graphFile.eof())
{
graphFile >> originVertex;
graphFile >> destinyVertex;
graph.addEdge(originVertex, destinyVertex);
graph2.addEdge(originVertex, destinyVertex);
}
runTopologicalSorting(0, graph, dfsDataFile);
runTopologicalSorting(1, graph2, kahnDataFile);
counter++;
graphFile.close();
}
dfsDataFile.close();
kahnDataFile.close();
initGraphicVisualization();
cout << "=====================================================================================================================================" << endl;
cout << "A conclusão sobre os resultados do gráfico podem ser encontrados no README.md" << endl;
cout << "As ordenações topológicas se encontram na pasta raiz do projeto, com o seguinte formato: topological-order-<algoritmo>-<vertices>.txt" << endl;
cout << "=====================================================================================================================================" << endl;
return 0;
}