-
Notifications
You must be signed in to change notification settings - Fork 0
/
vPrimeToUse.h
108 lines (85 loc) · 2.92 KB
/
vPrimeToUse.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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* BetaCome: betacome of future network routing
*
* Code to accompany the competition:
* huawei software challenge : future network routing,
* Yuanyuan Qin, Song Tang,2016
*
* Copyright (C) 2016 Yuanyuan Qin, Peking University, Shenzhen, China
*
* This file is part of BetaCome.
*
* BetaCome is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* BetaCome is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with BetaCome. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef _VPRIMETOUSE_H
#define _VPRIMETOUSE_H
#include "environment.h"
#include <list>
#include "point.h"
#include "graphBase.h"
#include "path.h"
#include <algorithm>
#include <iostream>
using namespace std;
class VPrimeToUse
{
public:
VPrimeToUse(){};
VPrimeToUse(GraphBase &graph, Path &path);
//return the iter after last point of current scc num
list<Point>::iterator curSccEnd(GraphBase &graph, Path &path);
//insert vprime point to list(the position is according to scc),return iter of it
list<Point>::iterator insertVPrime(GraphBase &graph, Path &path, int vPrimeId);
//delete a vprime,and return the lter after it
list<Point>::iterator deleteVPrime(list<Point>::iterator iter);
void sortVPrime();//sort vprimevector
//copy valid vprime point to vprimetouse
int refreshVPrime(GraphBase &graph, Path &path);
int refreshAgainVPrime(GraphBase &graph, Path &path);//random order of vprime
//iter of list
inline list<Point>::iterator begin(){ return vPrime2Use.begin(); }
inline list<Point>::iterator end(){ return vPrime2Use.end(); }
inline int empty(){ return vPrime2Use.empty(); }
int deleteUsedVPrime(GraphBase &graph, Path &path);//delete vprime that has been used
//get value
inline int getTopoOrderMax() const { return topoOrderMax; }
inline int getTopoOrderMin() const { return topoOrderMin; }
void printVprime();//print all vprime points in vprime2use
int randomOrder();//random the order of vprime belong to the same scc
private:
list<Point> vPrime2Use;
int topoOrderMax = 0;
int topoOrderMin = 0;
//exchange 2 elements of vprime
inline int exchange(int ii, int jj)
{
Point pointTemp;
list<Point>::iterator iterIi = vPrime2Use.begin();
list<Point>::iterator iterJj = vPrime2Use.begin();
for (int i = 0; i < ii; ++i)
{
++iterIi;
}
for (int i = 0; i < jj; ++i)
{
++iterJj;
}
pointTemp = (*iterIi);
(*iterIi) = (*iterJj);
(*iterJj) = pointTemp;
return EXIT_SUCCESS;
}
};
#endif