-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlift_to_front_graph.cpp
More file actions
45 lines (41 loc) · 1.14 KB
/
lift_to_front_graph.cpp
File metadata and controls
45 lines (41 loc) · 1.14 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
//
// Created by andrea on 09/09/18.
//
#include <iostream>
#include <algorithm>
#include "lift_to_front_graph.h"
void LiftToFrontGraph::printCurrentStatus() {
BaseGraph::printCurrentStatus();
if (this->verbose) {
std::cout << " L = { ";
for (int &index : this->list) {
std::cout << index << " ";
}
std::cout << "}" << std::endl;
}
}
void LiftToFrontGraph::preProcess(int s, int t) {
BaseGraph::preProcess(s, t);
for (int i = 0; i < this->vertices.size(); i++) {
if (i != s && i != t) {
this->list.push_back(i);
}
}
}
int LiftToFrontGraph::getActiveNode(int s, int t) {
for (int index : this->list) {
if (this->vertices[index].excess > 0) {
return index;
}
}
return NO_ACTIVE_NODE_FOUND;
}
bool LiftToFrontGraph::relabel(int u) {
bool relabeled = BaseGraph::relabel(u);
if (relabeled && this->list[0] != u) {
// the vertex u must be placed in front of the list L
auto it = std::find(this->list.begin(), this->list.end(), u);
std::rotate(this->list.begin(), it, it + 1);
}
return relabeled;
}