-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedge.cpp
More file actions
95 lines (70 loc) · 2.03 KB
/
edge.cpp
File metadata and controls
95 lines (70 loc) · 2.03 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "edge.h"
//Edge Functions
Edge::Edge():id(0), fromNodeId(0), toNodeId(0), weight(1), label(0){
}
Edge::Edge(int id, int fId, int tId, double w):id(id), fromNodeId(fId), toNodeId(tId), weight(w), label(0){
}
Edge::Edge(int id, int fId, int tId, int l):id(id), fromNodeId(fId), toNodeId(tId), weight(1), label(l){
}
Edge::Edge(int id, int fId, int tId, double w, int l):id(id), fromNodeId(fId), toNodeId(tId), weight(w), label(l){
}
int Edge::getId()const{
return this->id;
}
void Edge::setId(int id){
this->id = id;
}
int Edge::getFromNodeId()const{
return this->fromNodeId;
}
int Edge::getDistinctNodeId(int id)const{
if (this->fromNodeId!=id) return this->fromNodeId;
else return this->toNodeId;
}
void Edge::setFromNodeId(int id){
this->fromNodeId = id;
}
int Edge::getToNodeId()const{
return this->toNodeId;
}
void Edge::setToNodeId(int id){
this->toNodeId = id;
}
int Edge::getNodeIdDiffOf(int v) const {
if (this->fromNodeId!=v) return this->fromNodeId;
return this->toNodeId;
}
double Edge::getWeight()const{
return this->weight;
}
void Edge::setWeight(double w){
this->weight = w;
}
int Edge::getLabel()const{
return this->label;
}
void Edge::setLabel(int l){
this->label = l;
}
bool Edge::hasVertex(int v) {
if (fromNodeId==v || toNodeId==v) return true;
return false;
}
bool Edge::compareFromNodeId(const Edge &a, const Edge &b){
return (a.fromNodeId < b.fromNodeId);
}
bool Edge::compareToNodeId(const Edge &a, const Edge &b){
return (a.toNodeId < b.toNodeId);
}
bool Edge::compareToNodeIdEqual(const Edge &a, const Edge &b){
return (a.toNodeId == b.toNodeId);
}
bool Edge::compareLabel(const Edge &a, const Edge &b){
return (a.label < b.label);
}
bool Edge::compareWeight(const Edge &a, const Edge &b){
return (a.weight < b.weight);
}
void Edge::print(){
std::cout << "====edge fromNodeId " << fromNodeId << " toNodeId " << toNodeId << " weight " << weight << " label " << label << std::endl;
}