-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadh.h
66 lines (51 loc) · 2.52 KB
/
adh.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
/***************************************************************************
adh.h - description
-------------------
begin : Thu Oct 6 2005
copyright : (C) 2005 by Knut-Helge Vik
email : knuthelv@ifi.uio.no
***************************************************************************/
#ifndef GRAPHALGO_AVERAGE_DISTANCE_HEURISTIC_KHV
#define GRAPHALGO_AVERAGE_DISTANCE_HEURISTIC_KHV
#include "steiner_class.h"
#include "../treealgs/treealgs.h"
#include "../boostprop.h"
using namespace TreeAlgorithms;
class AverageDistanceHeuristic : public SteinerHeuristic
{
private:
TreeStructure &T_adh;
const GraphN &g;
TreeStructure inTree;
VertexSet steinerSet;
std::map<int, std::map<int, double> > fw_matrix; // Floyd-Warshall matrix
std::map<int, std::map<int, int > > parent_matrix; // Parent matrix from Floyd-Warshall
std::map<int, std::multimap<double, TreeStructure*> > dnt_matrix; // d(n,t) matrix
std::map<int, TreeStructure*> vertTOtree_map; // faster tree access
std::vector<TreeStructure*> TreeBundle_adh; // used when cleaning up
public:
AverageDistanceHeuristic(const TreeStructure &in, TreeStructure &out) : SteinerHeuristic(in), T_adh(out) , g(in.g), inTree(in) {}
~AverageDistanceHeuristic() { }
// Average Distance Heuristic main function
void Algorithm(int zsource);
// Average Distance Heuristic helper function
void RunFloydWarshall();
void FindMNode(int &fm_vert, int &fm_r);
void AddClosestZVertices(int fm_vert, int fm_r);
void AddEdges(int fm_vert, TreeStructure* pTadh_fm, TreeStructure* pTadh_nt);
double RaywardSmithf(int &r, double fn, int v, multimap<double, TreeStructure*>::iterator vit, multimap<double,TreeStructure*>::iterator vit_end);
// f(n) = min(1<=r<=k){ (sum of i=0 to r) d(n,t_i)/r:t_0,t_1,...,t_r in T}
// dump functions
void dumpParentMatrix();
void dumpFWMatrix();
void dumpDNTMatrix();
void dumpVertTOtreeMap();
void dumpAll();
// clean up
void cleanup();
//floyd_warshall_all_pairs_shortest_paths(g, fw_matrix, get(&EdgeProp::weight, g), compare, combine, std::numeric_limits<double>::max(), (double)0);
//floyd_warshall_all_pairs_shortest_paths(g, fw_matrix, weight_map(get(&EdgeProp::weight, g)));
//std::less<double> compare; // TODO: (unused) used when calling floyd-warshall as default
//std::plus<double> combine; // TODO: (unused) used when calling floyd-warshall as default
};
#endif /* GRAPHALGO_AVERAGE_DISTANCE_HEURISTIC_KHV */