This repository has been archived by the owner on Aug 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdge.h
67 lines (45 loc) · 1.38 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
#pragma once
#include "Common.h"
bool sortEdgesByWeight(const EdgePtr &l, const EdgePtr &r);
class Edge {
public:
Edge(const VertexPtr &src, const VertexPtr &dest, u_int32_t weight );
~Edge() = default;
Edge(const Edge& that)
: m_source(that.m_source.lock()),
m_destination(that.m_destination.lock()),
m_weight (that.m_weight)
{
}
Edge& operator=(const Edge& that)
{
m_destination = that.m_destination.lock();
m_source = that.m_source.lock();
m_weight = that.m_weight;
return *this;
}
const pair<VertexPtr,VertexPtr> getVertices() const;
const VertexPtr getSource() const;
const VertexPtr getDestination()const;
inline void setSource(const VertexPtr &vert){
m_source = vert;
}
inline void setDestination(const VertexPtr &vert){
m_destination = vert;
}
inline u_int32_t getWeight() const{
return m_weight;
}
inline void setWeight(u_int32_t w){
m_weight = w;
}
bool compareNamesUndirected(const Edge &edge) const;
bool comparePtrsUndirected(const Edge &edge) const;
bool compareNamesDirected(const Edge &edge) const;
bool comparePtrsDirected(const Edge &edge) const;
void print(bool withWeights) const;
private:
WeakVertexPtr m_source;
WeakVertexPtr m_destination;
u_int32_t m_weight;
};