-
Notifications
You must be signed in to change notification settings - Fork 0
/
Edge.h
executable file
·79 lines (66 loc) · 1.64 KB
/
Edge.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once
#include <iostream>
#include <string>
#include "Vertex.h"
using namespace std;
/**
* Set's up our edge in a graph
*/
class Edge {
public:
/**
* Default constructor for Edge class.
*/
Edge();
/**
* Constructor for our weighted graph edge
* @param s: source of edge
* @param d: destination of edge
* sets the weight and label based on parameters of vectors
*/
Edge(Vertex s, Vertex d);
/**
* Compares two edges using their weights
* @param other - edge to be compared
* @return if this edge is less than param
*/
bool operator<(const Edge &other) const;
/**
* Gets the label of the edge
* @return label of edge
*/
string getLabel() const;
/**
* Gets the source of the edge
* @return source of edge
*/
string getSource() const;
/**
* Gets the destination of the edge
* @return destination of edge
*/
string getDestination() const;
/**
* Gets wieght of edge
* @return weight of edge
*/
double getWeight() const;
/**
* Compares two edges using source and destination
* @param other: edge to be compared
* @return if this edge equals the other
*/
bool operator==(const Edge &other) const;
private:
/**
* Calculates the haversine distance between two points
* @param first: first point
* @param second: second point
* @return haversine distance
*/
double haversine(Vertex first, Vertex second) const;
Vertex source; // source of edge
Vertex destination; // destination of edge
string label; // edge label, a string concat of source+destination IATA code
double weight; // weight of edge, determined by haversine
};