-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEdge.cpp
More file actions
42 lines (31 loc) · 985 Bytes
/
Edge.cpp
File metadata and controls
42 lines (31 loc) · 985 Bytes
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
#include "Edge.hpp"
using namespace std;
Edge::Edge() {
}
Edge::Edge(Vertex *from, Vertex *to, unsigned int cost, unsigned int length) {
this->from = from; // Assign starting vertex
this->to = to; // Assign ending vertex
this->cost = cost; // Assign cost of edge
this->length = length; // Assign length of edge
}
Vertex* Edge::getFrom() const {
return this->from; // Obtain starting vertex of edge
}
Vertex* Edge::getTo() const {
return this->to; // Obtain ending vertex of edge
}
void Edge::setCost(unsigned int cost) {
this->cost = cost; // Assign cost of edge
}
unsigned int Edge::getCost () const {
return cost; // Obtain cost of edge
}
void Edge::setLength(unsigned int length) {
this->length = length; // Assign length of edge
}
unsigned int Edge::getLength() const {
return length; // Obtain length of edge
}
bool Edge::operator<(const Edge &right) const {
return cost < right.cost; // Sorts cost in increasing order in pq
}