![]() |
aGrUM
0.16.0
|
This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured inference. More...
#include <agrum/PRM/gspan.h>
Public Member Functions | |
Constructors & destructor. | |
GSpan (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0) | |
Default constructor. More... | |
~GSpan () | |
Destructor. More... | |
Getters and setters. | |
Size | getMaxDFSDepth () const |
Returns the maximal depth of the DFSTree used to discover new patterns. More... | |
void | setMaxDFSDepth (Size depth) |
Defines the maximal depth of the DFSTree used by this class to discover new patterns. More... | |
gspan::DFSTree< GUM_SCALAR > & | tree () |
Returns the DFSTree used to discover new patters. More... | |
const gspan::DFSTree< GUM_SCALAR > & | tree () const |
Returns the DFSTree used to discover new patters. More... | |
gspan::InterfaceGraph< GUM_SCALAR > & | interfaceGraph () |
Returns the InterfaceGraph used by this. More... | |
const gspan::InterfaceGraph< GUM_SCALAR > & | interfaceGraph () const |
Returns the InterfaceGraph used by this. More... | |
Classes | |
class | LabelSort |
Private class used to sort LabelData using STL sort algorithms. More... | |
class | PatternSort |
Private class used to sort Pattern using STL sort algorithms. More... | |
Pattern discovery methods. | |
typedef Set< Sequence< PRMInstance< GUM_SCALAR > *> *> | MatchedInstances |
Code alias. More... | |
void | discoverPatterns () |
This will methods will discover repeated patterns in the PRMSystem<GUM_SCALAR> assigned to this class. More... | |
std::vector< gspan::Pattern *> & | patterns () |
Returns the Pattern mined by this class in a decreasing order of interest. More... | |
const std::vector< gspan::Pattern *> & | patterns () const |
Returns the Pattern mined by this class in a decreasing order of interest. More... | |
MatchedInstances & | matches (const gspan::Pattern &p) |
Returns a mapping between patterns and the sequence of instance in the interface graph matching them. More... | |
const MatchedInstances & | matches (const gspan::Pattern &p) const |
Returns a mapping between patterns and the sequence of instance in the interface graph matching them. More... | |
This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured inference.
This class is not an inference algorithm for PRM<GUM_SCALAR>, however it can be used to speed up structured inference as it will discover repeated patterns including more than one PRMInstance<GUM_SCALAR>.
This algorithm proceeds in three main steps represented by the private methods GSpan::__sortNodesAndEdges(), GSpan::__subgraph_mining() and GSpan::__sortPatterns().
typedef Set< Sequence< PRMInstance< GUM_SCALAR >* >* > gum::prm::GSpan< GUM_SCALAR >::MatchedInstances |
INLINE gum::prm::GSpan< GUM_SCALAR >::GSpan | ( | const PRM< GUM_SCALAR > & | prm, |
const PRMSystem< GUM_SCALAR > & | sys, | ||
gspan::SearchStrategy< GUM_SCALAR > * | strategy = 0 |
||
) |
Default constructor.
prm | The PRM<GUM_SCALAR> used by this class. |
sys | The PRMSystem<GUM_SCALAR> on which this class searches for patterns. |
strategy | The search strategy used for pattern mining, the default strategy is gspan::FrequenceSearch. |
Definition at line 355 of file gspan_tpl.h.
INLINE gum::prm::GSpan< GUM_SCALAR >::~GSpan | ( | ) |
Destructor.
Definition at line 364 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__graph, and gum::prm::GSpan< GUM_SCALAR >::__matched_instances.
|
private |
Returns the cost with respect to an interface size and its frequency. TODO replace this by a class to enable different cost policies.
interface_size | The size of all output nodes of a pattern. |
frequency | The frequency of the pattern in the current interface graph. |
Definition at line 394 of file gspan_tpl.h.
|
private |
Returns true if e is an eligible root edge.
e | An EdgeData<GUM_SCALAR>. |
Definition at line 436 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__graph, gum::prm::gspan::EdgeData< GUM_SCALAR >::l, gum::prm::gspan::EdgeData< GUM_SCALAR >::l_u, and gum::prm::gspan::EdgeData< GUM_SCALAR >::l_v.
|
private |
Sort the nodes and edges of __graph.
Definition at line 59 of file gspan_tpl.h.
|
private |
Sort the patterns and compute their respective costs.
Definition at line 225 of file gspan_tpl.h.
References gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::EdgeGraphPart::existsEdge(), gum::Set< Key, Alloc >::insert(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::insert(), gum::EdgeGraphPart::neighbours(), and gum::NodeGraphPart::nodes().
|
private |
Discovers new patterns by developing p.
graph | The interface graph used in this discovery process. |
p | The pattern used as a base for discovery. |
Definition at line 103 of file gspan_tpl.h.
References gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::atPos(), gum::prm::gspan::Pattern::code(), gum::prm::gspan::DFSCode::codes, gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::edge(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::exists(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::graph(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::id(), gum::prm::gspan::EdgeGrowth< GUM_SCALAR >::insert(), gum::HashTable< Key, Val, Alloc >::insert(), gum::prm::gspan::EdgeData< GUM_SCALAR >::l, gum::prm::gspan::EdgeData< GUM_SCALAR >::l_u, gum::prm::gspan::EdgeData< GUM_SCALAR >::l_v, gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::node(), gum::SequenceImplementation< Key, Alloc, std::is_scalar< Key >::value >::pos(), gum::prm::gspan::Pattern::rightmostPath(), gum::prm::gspan::EdgeGrowth< GUM_SCALAR >::toString(), and gum::prm::gspan::EdgeData< GUM_SCALAR >::u.
void gum::prm::GSpan< GUM_SCALAR >::discoverPatterns | ( | ) |
This will methods will discover repeated patterns in the PRMSystem<GUM_SCALAR> assigned to this class.
The results are saved in a vector of Patterns which can be obtained by calling GSpan::patterns().
Definition at line 36 of file gspan_tpl.h.
References gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::graph(), and gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::id().
INLINE Size gum::prm::GSpan< GUM_SCALAR >::getMaxDFSDepth | ( | ) | const |
Returns the maximal depth of the DFSTree used to discover new patterns.
Definition at line 374 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__depth_stop.
INLINE gspan::InterfaceGraph< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::interfaceGraph | ( | ) |
Returns the InterfaceGraph used by this.
Definition at line 424 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__graph.
INLINE const gspan::InterfaceGraph< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::interfaceGraph | ( | ) | const |
Returns the InterfaceGraph used by this.
Definition at line 430 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__graph.
INLINE GSpan< GUM_SCALAR >::MatchedInstances & gum::prm::GSpan< GUM_SCALAR >::matches | ( | const gspan::Pattern & | p | ) |
Returns a mapping between patterns and the sequence of instance in the interface graph matching them.
Definition at line 412 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__matched_instances.
INLINE const GSpan< GUM_SCALAR >::MatchedInstances & gum::prm::GSpan< GUM_SCALAR >::matches | ( | const gspan::Pattern & | p | ) | const |
Returns a mapping between patterns and the sequence of instance in the interface graph matching them.
Definition at line 418 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__matched_instances.
INLINE std::vector< gspan::Pattern *> & gum::prm::GSpan< GUM_SCALAR >::patterns | ( | ) |
Returns the Pattern mined by this class in a decreasing order of interest.
Definition at line 400 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__patterns.
INLINE const std::vector< gspan::Pattern *> & gum::prm::GSpan< GUM_SCALAR >::patterns | ( | ) | const |
Returns the Pattern mined by this class in a decreasing order of interest.
Definition at line 406 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__patterns.
INLINE void gum::prm::GSpan< GUM_SCALAR >::setMaxDFSDepth | ( | Size | depth | ) |
Defines the maximal depth of the DFSTree used by this class to discover new patterns.
depth | The new maximal DFSTree depth. |
Definition at line 379 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__depth_stop.
INLINE gspan::DFSTree< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::tree | ( | ) |
Returns the DFSTree used to discover new patters.
Definition at line 384 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__tree.
Referenced by gum::prm::GSpan< GUM_SCALAR >::PatternSort::operator()().
INLINE const gspan::DFSTree< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::tree | ( | ) | const |
Returns the DFSTree used to discover new patters.
Definition at line 389 of file gspan_tpl.h.
References gum::prm::GSpan< GUM_SCALAR >::__tree.
|
private |
|
private |
|
private |
The max depth allowed for the DSF tree.
Definition at line 222 of file gspan.h.
Referenced by gum::prm::GSpan< GUM_SCALAR >::getMaxDFSDepth(), and gum::prm::GSpan< GUM_SCALAR >::setMaxDFSDepth().
|
private |
|
private |
The interface graph used by this class.
Definition at line 216 of file gspan.h.
Referenced by gum::prm::GSpan< GUM_SCALAR >::__isEdgeEligible(), gum::prm::GSpan< GUM_SCALAR >::interfaceGraph(), and gum::prm::GSpan< GUM_SCALAR >::~GSpan().
|
private |
Mapping between a pattern and the multiset of instances matched to it.
Definition at line 238 of file gspan.h.
Referenced by gum::prm::GSpan< GUM_SCALAR >::matches(), and gum::prm::GSpan< GUM_SCALAR >::~GSpan().
|
private |
|
private |
The vector of discovered patters, in decreasing order of interest.
Definition at line 225 of file gspan.h.
Referenced by gum::prm::GSpan< GUM_SCALAR >::patterns().
|
private |
The DFSTree used to discover new patters.
Definition at line 219 of file gspan.h.
Referenced by gum::prm::GSpan< GUM_SCALAR >::LabelSort::operator()(), and gum::prm::GSpan< GUM_SCALAR >::tree().