UnCoVer (Using Coverability for Verification)
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
StdMatchFinder Class Reference

StdMatchFinder provides a simple algorithm which takes two arbitrary graphs and calculates all matchings from one to the other. More...

#include <StdMatchFinder.h>

Public Member Functions

 StdMatchFinder (bool injective=false, bool stopFast=false)
 Generates a new instance of StdMatchFinder. More...
 
virtual ~StdMatchFinder ()
 Destroys the current instance of StdMatchFinder.
 
void setInjectivity (bool injective)
 Sets whether this matcher should generate injective matches or not. More...
 
bool matchesInjectively () const
 Returns whether this matcher generates injective or non-injective matches. More...
 
void setStopOnFirstFind (bool stopFast)
 Sets whether this matcher should stop after the first matching found. More...
 
bool stopsOnFirstFind () const
 Returns whether the matcher will stop after finding the first match. More...
 
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. More...
 

Protected Member Functions

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 induced mapping on the nodes. More...
 
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. More...
 
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. More...
 
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. More...
 
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 the target graph. More...
 
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. More...
 

Private Attributes

bool matchInjective
 Stores whether the used matches should injective or not.
 
bool stopOnFirstFind
 Stores whether the matcher should stop after finding at least one match.
 

Detailed Description

StdMatchFinder provides a simple algorithm which takes two arbitrary graphs and calculates all matchings from one to the other.

The Matcher can calculate injective as well as non-injective matches and can search for all or just one match. The result is a collection of Mappings.

Author
Jan Stückrath
See Also
graphs::Hypergraph
graphs::Mapping

Constructor & Destructor Documentation

StdMatchFinder ( bool  injective = false,
bool  stopFast = false 
)

Generates a new instance of StdMatchFinder.

No further initialization is necessary.

Parameters
injectiveset to true, if only injective matches should be returned
stopFastset to true, if the computation should be stoped after the first match is found

Member Function Documentation

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
protected

This method recursively enumerates through all possibilities to map the isolated nodes injectively to the target graph.

For each such possibility a new Mapping is added to the collection of all Mappings.

Parameters
isolatedNodesa vector containing all isolated nodes of the source graph
isolatedNodesPosthe current position in the list of isolated nodes, a map is searched for; initially has to be 0
targetsa collection of all nodes of the target graph, where the isolated nodes can be mapped to; has to be all nodes of the target graph not already mapped to
noTargetsa set of all targets already used for isolated node mapping; initially has to be an empty set
currentMappingthe currently worked on (partial) Mapping
allMappingsa collection, where all resulting Mappings will be stored; should be empty initially
void enumAllIsoNodesNonInj ( vector< IDType > &  isolatedNodes,
vector< IDType > &  targets,
graphs::Mapping currentMapping,
shared_ptr< vector< graphs::Mapping >>  allMappings 
) const
protected

Enumerates through all possibilities to map the isolated nodes non-injectively to the target graph.

For each such possibility a new Mapping is added to the collection of all Mappings.

Parameters
isolatedNodesa vector containing all isolated nodes of the source graph
targetsa collection of all nodes of the target graph, where the isolated nodes can be mapped to; has to be all nodes of the target graph
currentMappingthe currently worked on (partial) Mapping
allMappingsa collection, where all resulting Mappings will be stored; should be empty initially
shared_ptr< vector< 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.

According to the parameter it is either searched for injective or non-injective matches. Instead of searching for all possible matches, the procedure can also terminate after the first match is found. In any case a list of the possible matches is returned.

Parameters
sourcethe source graph, which is mapped to the target graph
targetthe target graph, which is mapped from the source graph
Returns
a collection of all matchings from the source graph to the target graph (an empty collection, if none exist)
IDType getNewEntryPoint ( graphs::AnonHypergraph const &  source,
graphs::Mapping const &  currentMapping 
) const
protected

Searched for an unmapped edge in the source graph according to a simple optimization criterion.

This criterion is: has the maximal arity.

Parameters
sourcethe graph to search in
currentMappingthe currently worked on (partial) Mapping
Returns
the ID of the "best" unmapped edge
bool isMapPossible ( graphs::AnonHypergraph const &  source,
IDType  srcEdge,
graphs::AnonHypergraph const &  target,
IDType  tarEdge,
graphs::Mapping currentMapping,
graphs::Mapping revCurrentMapping 
) const
protected

Checks if a given edge of the source graph can be mapped to a given edge of the target graph.

This includes checking for label equality and if the result is still a Mapping (and not a relation). If necessary, the injectivity of the Mapping is also checked.

Parameters
sourcethe source graph
srcEdgethe source edge ID to check (must be part of the source graph)
targetthe target graph
tarEdgethe target edge ID to check (must be part of the target graph)
currentMappingthe currently worked on (partial) Mapping
revCurrentMappingthe reverse of currentMapping; only used if injective=true
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
protected

Maps all edges of the target graph recursively to all edges of the source graph, including the induced mapping on the nodes.

Either searches for one or all Mappings. These Mappings can be restricted to be injective.

Parameters
sourcethe source graph, the Mapping maps from
targetthe target graph, the Mapping maps to
edgesToGothe number of edges of the source graph, which still have to be mapped; initially this has to be the number of edges of the source graph
mappableEdgesa working set of edges, which are not yet mapped, but attached to already mapped nodes; initially this has to be an empty set
currentMappingthe currently worked on (partial) Mapping; initially has to be an empty Mapping
revCurrentMappingthe reverse of currentMapping; only used if injective=true; initially has to be an empty Mapping
foundMappingsthe steadily growing collection of found (total) Mappings; initially has to be an empty vector
shared_ptr< vector< Mapping > > mapIsolatedNodes ( graphs::AnonHypergraph const &  source,
graphs::AnonHypergraph const &  target,
shared_ptr< vector< graphs::Mapping >>  foundMappings 
) const
protected

Maps all isolated notes of the source graph to the target graph.

According to the parameters, either one or all Mappings are searched for and these Mappings must be injective or not. The result is returned as a vector of Mappings

Parameters
sourcethe source graph, mapped from
targetthe target graph, mapped to
foundMappingsthe collection of Mappings found so far, where the isolated nodes still need to be mapped
Returns
a vector containing all Mappings including mapped isolated nodes
bool matchesInjectively ( ) const

Returns whether this matcher generates injective or non-injective matches.

Returns
true, iff this matcher will generate only injective matches
void setInjectivity ( bool  injective)

Sets whether this matcher should generate injective matches or not.

Parameters
injective'true' will cause injective matches to be generated
void setStopOnFirstFind ( bool  stopFast)

Sets whether this matcher should stop after the first matching found.

Parameters
stopFast'true' will cause the matcher to stop after finding one match
bool stopsOnFirstFind ( ) const

Returns whether the matcher will stop after finding the first match.

return true, iff this matcher stops after finding the first match


The documentation for this class was generated from the following files: