-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdcsp.h
executable file
·135 lines (100 loc) · 3.52 KB
/
dcsp.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/***************************************************************************
dcsp.h - description
-------------------
begin : Thu Mar 22 2006
copyright : (C) 2005 by Knut-Helge Vik
email : knuthelv@ifi.uio.no
***************************************************************************/
#ifndef GRAPHALGO_DELAY_CONSTRAINED_SHORTEST_PATH_KHV
#define GRAPHALGO_DELAY_CONSTRAINED_SHORTEST_PATH_KHV
#include "steiner_class.h"
#include "../boostprop.h"
#include <vector>
using namespace boost;
using namespace std;
using namespace TreeAlgorithms;
/*-----------------------------------------------------------------------
class DelayConstrainedShortestPath
------------------------------------------------------------------------- */
class DelayConstrainedShortestPath : SteinerHeuristic
{
public:
DelayConstrainedShortestPath(const TreeStructure &in, TreeStructure &out) : SteinerHeuristic(in), T_dcsp_(out) {}
~DelayConstrainedShortestPath() {}
// typedefs definitions
enum COLOR { WHITE = 0, GRAY, BLACK};
typedef vector<double> DistanceVector;
typedef vector<vertex_descriptorN> ParentVector;
typedef vector<bool> BoolVector;
typedef vector<COLOR> ColorVector;
void Algorithm(vertex_descriptorN, double);
// class functions
void DCSP(vertex_descriptorN src, double delayLimit);
void DijkstraZ(vertex_descriptorN src);
bool createTree(vertex_descriptorN src, TreeStructure& treeStructure, bool zintree, const ParentVector &zparent);
void combineTrees(const TreeStructure &treeDCSP, const TreeStructure &treeZ);
void removeLoops(vertex_descriptorN src, double delayLimit, const TreeStructure &treeDCSP, const TreeStructure &treeZ);
void removeFromTree(const ParentVector &zparent, vertex_descriptorN intersection, vertex_descriptorN src);
void init();
private:
TreeStructure &T_dcsp_;
ColorVector colorDCSP_, colorZ_;
DistanceVector zdistanceDCSP_, zcostDCSP_;
ParentVector zparentDCSP_;
DistanceVector zdistanceZ_;
ParentVector zparentZ_;
BoolVector zintree_;
};
/*
class AnEdge
{
public:
AnEdge(edge_descriptorN e, GraphN g) : g_(g), e_(e) {}
~AnEdge() {}
edge_descriptorN e_;
GraphN g_;
};
class AnEdge
{
public:
AnEdge(EdgeId e) : e_(e) {}
~AnEdge() {}
EdgeId e_;
};
struct CompareEdges
{
bool operator()(AnEdge edgeE, AnEdge edgeF) const
{
vertex_descriptorN src_e = source(edgeE.e_, edgeF.g_), targ_e = target(edgeE.e_, edgeF.g_);
vertex_descriptorN src_f = source(edgeF.e_, edgeF.g_), targ_f = target(edgeF.e_, edgeF.g_);
cerr << "(" << src_e << "," << targ_e << ")" << endl;
cerr << "(" << src_f << "," << targ_f << ")" << endl;
if(src_e == src_f && targ_e == targ_f)
{
cerr << " Found match " << endl;
cerr << " src_e == src_f " << src_e << " == " << src_f << endl;
cerr << " targ_e == targ_f " << targ_e << " == " << targ_f << endl;
char c = getchar();
return false;
}
if(src_e == targ_f && targ_e == src_f)
{
cerr << " Found match " << endl;
cerr << " src_e == targ_f " << src_e << " == " << targ_f << endl;
cerr << " targ_e == src_f " << targ_e << " == " << src_f << endl;
char c = getchar();
return false;
}
return true;
}
bool operator()(AnEdge edgeE, AnEdge edgeF) const
{
cerr << edgeE.e_ << " == " << edgeF.e_ << "?" << endl;
if(edgeE.e_ == edgeF.e_)
return false;
cerr << " Edges are not the same " << endl;
return true;
}
};
*/
#endif // GRAPHALGO_DELAY_CONSTRAINED_SHORTEST_PATH_KHV