main page
namespaces
classes
files
GGL home
Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by
doxygen
1.8.3.1
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
src
sgm
MR_SymmBreak.hh
Go to the documentation of this file.
1
#ifndef SGM_MR_SYMMBREAK_HH_
2
#define SGM_MR_SYMMBREAK_HH_
3
4
#include "
sgm/Match_Reporter.hh
"
5
#include "
sgm/Pattern_Automorphism.hh
"
6
7
8
namespace
sgm {
9
10
/*! @brief Symmetry breaking among matches
11
*
12
* An sgm::Match_Reporter implementation that wraps another
13
* Match_Reporter and utilizes an sgm::Pattern_Automorphism to determine
14
* if a reported match is a symmetric solution or not. If not the match
15
* is forwarded to the provided second reporter.
16
*
17
* @author Martin Mann (c) 2008 http://www.bioinf.uni-freiburg.de/~mmann/
18
*/
19
class
MR_SymmBreak
:
public
Match_Reporter
{
20
21
protected
:
22
23
//! the Pattern_Automorphism used to check for symmetries
24
const
Pattern_Automorphism
*
symmCheck
;
25
//! the reporter to forward all non-symmetric matches to
26
Match_Reporter
*
forward
;
27
28
public
:
29
30
/*! Construction
31
*
32
* @param symmCheck the automorphism checker to apply to the pattern
33
* and match reported.
34
* @param forward the reporter to forward all non-symmetric matches to
35
*/
36
MR_SymmBreak
(
const
Pattern_Automorphism
&
symmCheck
37
,
Match_Reporter
&
forward
);
38
39
/*! Copy construction
40
*
41
* @param toCopy the object to make this a copy of
42
*/
43
MR_SymmBreak
(
const
MR_SymmBreak
& toCopy );
44
45
//! Destruction
46
virtual
47
~MR_SymmBreak
();
48
49
MR_SymmBreak
&
50
operator=
(
const
MR_SymmBreak
& toCopy );
51
52
//! Checks if the match is symmetric and if not forwards the match
53
//! to the other provided reporter.
54
//! @param pattern the pattern graph that was searched for
55
//! @param target the graph the pattern was found within
56
//! @param match contains the indices of the matched pattern nodes in
57
//! the target graph. match[i] corresponds to the mapping of the ith
58
//! vertex in the pattern graph.
59
virtual
60
void
61
reportHit
(
const
Pattern_Interface
& pattern,
62
const
Graph_Interface
& target,
63
const
Match
& match );
64
65
66
};
67
68
}
// namespace sgm
69
70
// IMPLEMENTATION OF MR_SymmBreak
71
72
namespace
sgm {
73
74
inline
75
MR_SymmBreak
76
::MR_SymmBreak
(
const
Pattern_Automorphism
& symmCheck_
77
,
Match_Reporter
& forward_ )
78
: symmCheck(symmCheck_.clone())
79
, forward(&forward_)
80
{}
81
82
inline
83
MR_SymmBreak
84
::MR_SymmBreak
(
const
MR_SymmBreak
& toCopy )
85
: symmCheck(toCopy.symmCheck->clone())
86
, forward(toCopy.forward)
87
{}
88
89
inline
90
MR_SymmBreak
91
::~MR_SymmBreak
( )
92
{
93
if
(symmCheck != NULL)
delete
symmCheck;
94
symmCheck = NULL;
95
}
96
97
inline
98
MR_SymmBreak
&
99
MR_SymmBreak
100
::operator=
(
const
MR_SymmBreak
& toCopy )
101
{
102
// deep copy
103
if
(symmCheck != NULL)
104
delete
symmCheck;
105
symmCheck = toCopy.
symmCheck
->
clone
();
106
// flat copy
107
forward = toCopy.
forward
;
108
// access to the changed *this object
109
return
*
this
;
110
}
111
112
inline
113
void
114
MR_SymmBreak
115
::reportHit
(
const
Pattern_Interface
& pattern,
116
const
Graph_Interface
& target,
117
const
Match
& match )
118
{
119
// check if symmetric
120
if
(!symmCheck->isSymmetryMatch( pattern, match )) {
121
// non-symmetric hits are forwarded
122
forward->reportHit( pattern, target, match );
123
}
124
}
125
126
}
127
128
#endif
/*MR_SYMMBREAK_HH_*/