-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphEdge.cpp
More file actions
86 lines (71 loc) · 1.61 KB
/
GraphEdge.cpp
File metadata and controls
86 lines (71 loc) · 1.61 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
#include "GraphEdge.h"
namespace AlgoGraph
{
GraphEdge::GraphEdge() : GraphEdge(0, 0) {}
GraphEdge::GraphEdge(int o_OutVertex, int o_InVertex, float o_edgeWeight)
{
m_Weight.weight = o_edgeWeight;
m_Weight.infinity = false;
m_OutVertex = o_OutVertex;
m_InVertex = o_InVertex;
}
GraphEdge::GraphEdge(int o_OutVertex, int o_InVertex)
{
m_Weight.weight = 1;
m_Weight.infinity = true;
m_OutVertex = o_OutVertex;
m_InVertex = o_InVertex;
}
/*get edge weight is a bool function ->
if weight is infinity returns true,
if not the weight returns as refrenced value and function returns false*/
bool GraphEdge::GetEdgeWeight(float& o_weight)
{
if (m_Weight.infinity == false)
{
o_weight = m_Weight.weight;
return false;
}
else return true;
}
Weight GraphEdge::GetEdgeWeight()
{
return m_Weight;
}
bool GraphEdge::IsWeightInfinity()
{
return m_Weight.infinity;
}
//o_inf default value for set is false, because set means setting actual value and not infinity
void GraphEdge::SetEdgeWeight(float o_weight)
{
m_Weight.weight = o_weight;
m_Weight.infinity = false;
}
void GraphEdge::SetInfinityWeight()
{
m_Weight.infinity = true;
}
void GraphEdge::SetInVertex(int o_InVertex)
{
m_InVertex = o_InVertex;
}
void GraphEdge::SetOutVertex(int o_OutVertex)
{
m_OutVertex = o_OutVertex;
}
int GraphEdge::GetInVertex()
{
return m_InVertex;
}
int GraphEdge::GetOutVertex()
{
return m_OutVertex;
}
bool GraphEdge::operator==(const GraphEdge& other)
{
if (m_InVertex == other.m_InVertex && m_OutVertex == other.m_OutVertex)
return true;
else return false;
}
}