-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathEdge.cpp
More file actions
33 lines (26 loc) · 903 Bytes
/
Edge.cpp
File metadata and controls
33 lines (26 loc) · 903 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
#include "Edge.h"
#include <cassert>
/// Do not use,just so Edge can be in a map. TODO: find a way to remove this!
Edge::Edge(){
}
/// Constructs an Edge from the specfieid Nodes and of the specified weight.
Edge::Edge(const Node &from, const Node &to, int weight): from_(from), to_(to), weight_(weight){
// make sure the from and to Edges are not the same Edge, that makes no sense
assert(!(from == to));
}
/// Returns the starting Node of the Edge.
Node Edge::from() const{
return from_;
}
/// Returns the ending Node of the Edge.
Node Edge::to() const{
return to_;
}
/// Returns the weight of the Edge.
int Edge::weight() const{
return weight_;
}
/// Returns true if the two edges have the same starting and ending Nodes, _regardeless of their weights_.
bool operator==(const Edge &lhs, const Edge &rhs){
return (lhs.from() == rhs.from()) && (lhs.to() == rhs.to());
}