-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.h
62 lines (42 loc) · 1.46 KB
/
Graph.h
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
#ifndef DA_TP_CLASSES_GRAPH
#define DA_TP_CLASSES_GRAPH
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <limits>
#include <algorithm>
#include <climits>
#include <execution>
#include <unordered_map>
#include "VertexEdge.h"
#include "Reservoir.h"
#include "PumpingStation.h"
#include "City.h"
class Graph {
public:
~Graph();
const unordered_map<std::string, Vertex *> & getVertexMap() const;
Vertex * findVertex(const std::string &code) const;
bool addVertex(const Reservoir& reservoir);
void removeVertex(Vertex* vertex);
bool addVertex(const PumpingStation& pumpingStation);
bool addVertex(const City& city);
bool addVertex(Vertex* vertex);
double getMaxFlowToCity(const std::string& cityCode);
void printGraph(const Graph& graph);
void resetFlows(Graph& graph);
double edmondsKarp(Vertex* s, Vertex* t);
protected:
std::unordered_map<std::string, Vertex *> vertexMap;
double ** distMatrix = nullptr;
double **pathMatrix = nullptr;
bool bfs(Vertex *source, Vertex *sink) const;
static void updateFlow(Vertex* sink, int bottleneck);
static double findMinResidualAlongPath(Vertex *s, Vertex *t);
bool findAugmentingPath(Vertex *s, Vertex *t);
static void testAndVisit(queue<Vertex *> &q, Edge *e, Vertex *w, double residual);
static void augmentFlowAlongPath(Vertex *s, Vertex *t, double f);
};
void deleteMatrix(double **m, int n);
#endif /* DA_TP_CLASSES_GRAPH */