-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDFSAPHeuristic.h
107 lines (91 loc) · 3.62 KB
/
DFSAPHeuristic.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
/*
* steghide 0.5.1 - a steganography program
* Copyright (C) 1999-2003 Stefan Hetzl <[email protected]>
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef SH_DFSAPHEURISTIC
#define SH_DFSAPHEURISTIC
#include "EdgeIterator.h"
#include "MatchingAlgorithm.h"
#include "Vertex.h"
class Edge ;
#include "Graph.h"
class Matching ;
/**
* \class DFSAPHeuristic
* \brief a matching algorithm implementing a heuristic search for augmenting paths
*
* This class implements the heuristic augmenting path search presented by
* Rolf H. Moehring and Matthias Mueller-Hannemann in their paper: "Cardinality
* Matching: Heuristic Search for Augmenting Paths".
**/
class DFSAPHeuristic : public MatchingAlgorithm {
public:
/**
* construct an DFSAPHeuristic object
* \param g the graph on which this heuristic should run
* \param m the matching to start with
* \param goal the percentage of matched vertices that should be reached
* \param mne the maximum number of edges that should be considered for every vertex
* \param mo the mode for edge iteration
**/
DFSAPHeuristic (Graph* g, Matching* m, float goal = 100.0, UWORD32 mne = UWORD32_MAX, EdgeIterator::ITERATIONMODE mo = EdgeIterator::SAMPLEOCCURENCE) ;
virtual ~DFSAPHeuristic (void) ;
const char* getName (void) const
{ return "DFS Augmenting Path Heuristic" ; } ;
/**
* reset the state of this DFSAPHeuristic, esp. the EdgeIterators
* \param mne the maximum number of edges that should be considered for every vertex for now on
**/
void reset (UWORD32 mne = UWORD32_MAX, EdgeIterator::ITERATIONMODE mo = EdgeIterator::SAMPLEOCCURENCE) ;
void run (void) ;
private:
/**
* \param v0 an exposed vertex
* \param path an array of Edge pointers where the path will be put
* \return the length of the path (the number of valid edges in path)
**/
unsigned long searchAugmentingPath (Vertex* v0, const Edge** path) ;
const Edge* getNextEdge (Vertex *v) ;
void markVisited (Vertex *v)
{ TimeCounters[v->getLabel()] = TimeCounter ; } ;
/**
* returns true iff v has already been visited in this
* iteration, i.e. in the current call of searchAugmentingPath
**/
bool isVisited (Vertex *v) const
{ return isVisited(v->getLabel()) ; } ;
bool isVisited (VertexLabel vlbl) const
{ return (TimeCounters[vlbl] == TimeCounter) ; } ;
UWORD32 TimeCounter ;
UWORD32* TimeCounters ;
bool* VertexOnPath ;
EdgeIterator* EdgeIterators ;
#ifdef DEBUG
/// the number of edges that have been examined in all successful searches
unsigned long long NEdgesSuccessful ;
/// the number of edges that have been examined in all unsuccessful searches
unsigned long long NEdgesUnsuccessful ;
/// the number of calls to searchAugmentingPath that have been sucessful
unsigned long NSuccessful ;
/// the number of calls to searchAugmentingPath that have been unsuccessful
unsigned long NUnsuccessful ;
/// string indicating if n-th search was successful
std::string SuccessString ;
#endif
} ;
#endif // ndef SH_DFSAPHEURISTIC