-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
44 lines (40 loc) · 1.25 KB
/
Main.cpp
File metadata and controls
44 lines (40 loc) · 1.25 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
#include <iostream>
#include "Graph.h"
#include "MaxFlowAlgorithms.h"
void printResult(FordFulkersonAnswer& answer , std::string&& type);
int main(){
Graph g = Graph();
try{
g.buildGraph();
}catch (std::invalid_argument& e){
std::cout << e.what();
exit(0);
}
FordFulkersonAnswer answer1 = MaxFlowAlgorithms::fordFulkersonWithBfs(g);
printResult(answer1, "BFS");
std::cout<<std::endl;
FordFulkersonAnswer answer2 = MaxFlowAlgorithms::fordFulkersonWithDijkstra(g);
printResult(answer2, "Greedy");
}
void printResult(FordFulkersonAnswer& answer , std::string&& type){
std::cout << type << " Method:" << std::endl;
std::cout<< "Max flow = " << answer.getMaxFlow() << std::endl;
std::cout << "Min cut: S = ";
int size = answer.getLeft().size();
for(int i = 0; i < size; ++i){
if(i == size -1){
std::cout << answer.getLeft()[i] << ".";
} else{
std::cout << answer.getLeft()[i] << ", ";
}
}
std::cout << " T = ";
size = answer.getRight().size();
for(int i = 0; i < size; ++i){
if(i == size -1){
std::cout << answer.getRight()[i];
} else{
std::cout << answer.getRight()[i] << ", ";
}
}
}