-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedge.h
74 lines (65 loc) · 1.52 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
#pragma once
#include <map>
//TODO: vertex and edge should have each one classes in order to satisty whole class hierarchy polymorphic behaviour
//edges shall be adopted according to graph
enum class EdgeDirection
{
UNDIRECTED = 1,
FIRST_TO_SECOND,
SECOND_TO_FIRST
};
class Edge
{
public:
Edge(int iOne, int iSecond);
int First() const
{
return m_Edge.first;
}
int Second() const
{
return m_Edge.second;
}
void SetFirst(int iOne)
{
m_Edge.first = iOne;
}
void SetSecond(int iTwo)
{
m_Edge.second = iTwo;
}
bool IsSelfLoop() const
{
return m_Edge.first == m_Edge.second;
}
int Weight() const
{
return m_iWeight;
}
virtual EdgeDirection Direction() const
{
return m_direction;
}
friend bool operator<(const Edge &edge1, const Edge &edge2);
friend bool operator==(const Edge &edge1, const Edge &edge2);
protected:
EdgeDirection m_direction;
int m_iWeight;
private:
std::pair<int, int> m_Edge;
};
class DirectedEdge: virtual public Edge
{
public:
DirectedEdge(int iFirst, int iSecond, const EdgeDirection &direction);
};
class WeightEdge: virtual public Edge
{
public:
WeightEdge(int iFirst, int iSecond, int iWeight);
};
class DirectedWeightEdge: public DirectedEdge, public WeightEdge
{
public:
DirectedWeightEdge(int iOne, int iTwo, const EdgeDirection &direction, int iWeight);
};