-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.cpp
More file actions
66 lines (57 loc) · 1.32 KB
/
Node.cpp
File metadata and controls
66 lines (57 loc) · 1.32 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
#include "Node.h"
//Add an edge to the edge list of the node
void Node::addEdge(EdgeEntry* edge)
{
assert(lastEdge); //lastEdge is never null (initialized with dummy)
lastEdge->nextEdge = edge;
edge->prevEdge = lastEdge;
lastEdge = edge;
numEdges++;
}
//Node constructor
Node::Node()
{
degree = 0;
label = 0;
id = 0;
excess = 0;
adjList = new EdgeEntry(0, 0, 0, NULL);
lastEdge = adjList;
numEdges = 0;
}
//Decrement the excess of the node
void Node::decExcess(int value)
{
if (excess < value)
cout << "Error found in excess";
else
excess -= value;
}
//Print a node
void Node::printNode(ofstream & output)
{
EdgeEntry* listPtr = adjList->getNext();
while (listPtr != NULL)
{
output << this->getID() << "->" << listPtr->getEndPoint() << " (" << listPtr->getFlow() << ")" << endl;
listPtr = listPtr->getNext();
}
}
//Print the node debug dump info
void Node::debugNodeDump()
{
cout << getID() << ": ";
cout << getDegree() << ", \t";
cout << Utils::printValue(getLabel()) << ", \t";
cout << getExcess();
cout << endl;
}
//Overwrite the node "greater then" and "less then" operators
bool Node::operator>(const Node* node) const
{
return label > node->label;
}
bool Node::operator<(const Node* node) const
{
return label < node->label;
}