UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
StdMatchFinder.h
1 /***************************************************************************
2  * Copyright (C) 2014 by Jan Stückrath <jan.stueckrath@uni-due.de> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  * This program is distributed in the hope that it will be useful, *
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12  * GNU General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU General Public License *
15  * along with this program; if not, write to the *
16  * Free Software Foundation, Inc., *
17  * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
18  ***************************************************************************/
19 
20 #ifndef STDMATCHFINDER_H_
21 #define STDMATCHFINDER_H_
22 
23 #include "../basic_types/globals.h"
24 #include "../graphs/AnonHypergraph.h"
25 #include "../graphs/Mapping.h"
26 
27 namespace uncover {
28  namespace rule_engine {
29 
39 
40  public:
41 
47  StdMatchFinder(bool injective = false, bool stopFast = false);
48 
52  virtual ~StdMatchFinder();
53 
58  void setInjectivity(bool injective);
59 
64  bool matchesInjectively() const;
65 
70  void setStopOnFirstFind(bool stopFast);
71 
76  bool stopsOnFirstFind() const;
77 
88  shared_ptr<vector<graphs::Mapping>> findMatches(
89  graphs::AnonHypergraph const& source,
90  graphs::AnonHypergraph const& target) const;
91 
92  protected:
93 
111  void mapEdges(
112  graphs::AnonHypergraph const& source,
113  graphs::AnonHypergraph const& target,
114  size_t edgesToGo,
115  unordered_set<IDType>& mappableEdges,
116  graphs::Mapping& currentMapping,
117  graphs::Mapping& revCurrentMapping,
118  shared_ptr<vector<graphs::Mapping>> foundMappings) const;
119 
131  bool isMapPossible(
132  graphs::AnonHypergraph const& source,
133  IDType srcEdge,
134  graphs::AnonHypergraph const& target,
135  IDType tarEdge,
136  graphs::Mapping& currentMapping,
137  graphs::Mapping& revCurrentMapping) const;
138 
147  graphs::AnonHypergraph const& source,
148  graphs::Mapping const& currentMapping) const;
149 
159  shared_ptr<vector<graphs::Mapping>> mapIsolatedNodes(
160  graphs::AnonHypergraph const& source,
161  graphs::AnonHypergraph const& target,
162  shared_ptr<vector<graphs::Mapping>> foundMappings) const;
163 
177  void enumAllIsoNodesInj(
178  vector<IDType>& isolatedNodes,
179  size_t isolatedNodesPos,
180  vector<IDType>& targets,
181  unordered_set<IDType>& noTargets,
182  graphs::Mapping& currentMapping,
183  shared_ptr<vector<graphs::Mapping>> allMappings) const;
184 
194  void enumAllIsoNodesNonInj(vector<IDType>& isolatedNodes,
195  vector<IDType>& targets,
196  graphs::Mapping& currentMapping,
197  shared_ptr<vector<graphs::Mapping>> allMappings) const;
198 
199  private:
200 
205 
210 
211  };
212 
213  } /* namespace rule_engine */
214 } /* namespace uncover */
215 #endif /* MATCHFINDER_H_ */
void setInjectivity(bool injective)
Sets whether this matcher should generate injective matches or not.
Definition: StdMatchFinder.cpp:36
StdMatchFinder provides a simple algorithm which takes two arbitrary graphs and calculates all matchi...
Definition: StdMatchFinder.h:38
bool stopsOnFirstFind() const
Returns whether the matcher will stop after finding the first match.
Definition: StdMatchFinder.cpp:48
void setStopOnFirstFind(bool stopFast)
Sets whether this matcher should stop after the first matching found.
Definition: StdMatchFinder.cpp:44
This is the data structure representing a morphism mapping from a graph to another graph...
Definition: Mapping.h:36
void mapEdges(graphs::AnonHypergraph const &source, graphs::AnonHypergraph const &target, size_t edgesToGo, unordered_set< IDType > &mappableEdges, graphs::Mapping &currentMapping, graphs::Mapping &revCurrentMapping, shared_ptr< vector< graphs::Mapping >> foundMappings) const
Maps all edges of the target graph recursively to all edges of the source graph, including the induce...
Definition: StdMatchFinder.cpp:81
bool matchesInjectively() const
Returns whether this matcher generates injective or non-injective matches.
Definition: StdMatchFinder.cpp:40
bool isMapPossible(graphs::AnonHypergraph const &source, IDType srcEdge, graphs::AnonHypergraph const &target, IDType tarEdge, graphs::Mapping &currentMapping, graphs::Mapping &revCurrentMapping) const
Checks if a given edge of the source graph can be mapped to a given edge of the target graph...
Definition: StdMatchFinder.cpp:220
void enumAllIsoNodesInj(vector< IDType > &isolatedNodes, size_t isolatedNodesPos, vector< IDType > &targets, unordered_set< IDType > &noTargets, graphs::Mapping &currentMapping, shared_ptr< vector< graphs::Mapping >> allMappings) const
This method recursively enumerates through all possibilities to map the isolated nodes injectively to...
Definition: StdMatchFinder.cpp:345
StdMatchFinder(bool injective=false, bool stopFast=false)
Generates a new instance of StdMatchFinder.
Definition: StdMatchFinder.cpp:32
void enumAllIsoNodesNonInj(vector< IDType > &isolatedNodes, vector< IDType > &targets, graphs::Mapping &currentMapping, shared_ptr< vector< graphs::Mapping >> allMappings) const
Enumerates through all possibilities to map the isolated nodes non-injectively to the target graph...
Definition: StdMatchFinder.cpp:367
IDType getNewEntryPoint(graphs::AnonHypergraph const &source, graphs::Mapping const &currentMapping) const
Searched for an unmapped edge in the source graph according to a simple optimization criterion...
Definition: StdMatchFinder.cpp:204
bool stopOnFirstFind
Stores whether the matcher should stop after finding at least one match.
Definition: StdMatchFinder.h:209
An AnonHypergraph is a data structure storing a hypergraph.
Definition: AnonHypergraph.h:43
bool matchInjective
Stores whether the used matches should injective or not.
Definition: StdMatchFinder.h:204
shared_ptr< vector< graphs::Mapping > > findMatches(graphs::AnonHypergraph const &source, graphs::AnonHypergraph const &target) const
This method takes two graphs and calculates all matches from the source to the target graph...
Definition: StdMatchFinder.cpp:52
shared_ptr< vector< graphs::Mapping > > mapIsolatedNodes(graphs::AnonHypergraph const &source, graphs::AnonHypergraph const &target, shared_ptr< vector< graphs::Mapping >> foundMappings) const
Maps all isolated notes of the source graph to the target graph.
Definition: StdMatchFinder.cpp:265
virtual ~StdMatchFinder()
Destroys the current instance of StdMatchFinder.
Definition: StdMatchFinder.cpp:34
unsigned int IDType
IDType is an (unsigned) integer specifically used as an Identifier of graphs, elements of graphs or a...
Definition: globals.h:53