-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathEdge.h
More file actions
45 lines (38 loc) · 942 Bytes
/
Edge.h
File metadata and controls
45 lines (38 loc) · 942 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
42
43
44
45
#ifndef EDGE_H
#define EDGE_H
#include "Node.h"
/// Represents an edge between two Nodes.
/// @author Abdullah Aghazadah
/// @date 4-21-15
///
/// An Edge is defined by the value of its starting ("from") and ending ("to") Nodes. Therefore
/// two Edges are equivalent if they both start and end at the same (i.e. equivalent) Nodes.
///
/// @see Graph
class Edge{
public:
// construtors
Edge();
Edge(const Node& from, const Node& to, int weight);
// readers ("getters")
Node from() const;
Node to() const;
int weight() const;
private:
// main private attributes
int weight_;
Node from_;
Node to_;
};
// comparison operator
bool operator==(const Edge& lhs, const Edge& rhs);
// Make Edge hashable
namespace std {
template <> struct hash<Edge>
{
size_t operator()(const Edge& edge) const{
return hash<Node>()(edge.from()) + hash<Node>()(edge.to());
}
};
}
#endif // EDGE_H