-
Notifications
You must be signed in to change notification settings - Fork 4
/
GraphEdge.cpp
37 lines (32 loc) · 907 Bytes
/
GraphEdge.cpp
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
#include "GraphEdge.h"
GraphEdge::GraphEdge(int weight, GraphNode *Node1, GraphNode *Node2) {
this->Node1 = Node1;
this->Node2 = Node2;
this->weight = weight;
}
//Operator Over-ride in order to check if 2 edges are equal we check all the possible combinations of nodes.
bool GraphEdge::operator==(GraphEdge *edge) {
if (edge->Node1 == Node1) {
if (edge->Node2 == Node2)
return true;
} else if (edge->Node1 == Node2) {
if (edge->Node2 == Node1)
return true;
} else if (edge->Node2 == Node2) {
if (edge->Node1 == Node1)
return true;
} else if (edge->Node2 == Node1) {
if (edge->Node1 == Node2)
return true;
}
return false;
}
int GraphEdge::getWeight() {
return weight;
}
GraphNode *GraphEdge::getNode1() {
return Node1;
}
GraphNode *GraphEdge::getNode2() {
return Node2;
}