-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.h
More file actions
65 lines (41 loc) · 1.29 KB
/
Copy pathGraph.h
File metadata and controls
65 lines (41 loc) · 1.29 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
#pragma once
#include <iostream>
#include <algorithm>
#include "Vertex.h"
#include <vector>
#include <stdexcept>
class Graph{
private:
std::vector<Vertex> vertexes;
private:
Vertex* s = nullptr;
Vertex* t = nullptr;
public:
Graph(){}
Graph(const Graph& copyFrom){
this->makeEmptyGraph(copyFrom.getVertexesSize());
for(const Vertex& v : copyFrom.vertexes){
for(const Edge& e : v.getEdges()){
this->addEdge(e.getSrc(), e.getDest(), e.getCapacity());
}
}
this->s = &this->vertexes[copyFrom.s->getId() -1];
this->t = &this->vertexes[copyFrom.t->getId() -1];
}
void makeEmptyGraph(int numOfVertexes);
std::vector<Vertex> &getVertexes() ;
std::list<int> getAdjList(int vertexId);
void addEdge(int src, int dest, int weight);
void removeEdge(int src, int dest);
int getVertexesSize()const{return this->vertexes.size();}
const Vertex& getS() const;
Vertex& getS(){return *s;}
const Vertex& getT() const;
const Vertex& getVertexById(int id) const{
return vertexes[id -1];
}
Edge* getEdge(int src, int dest);
void printGraph();//test func
void validateInput(int numOfVertexes, int numOfEdges, int sId, int tId);
void buildGraph();
};