aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::prm::GSpan< GUM_SCALAR > Class Template Reference

This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured inference. More...

#include <agrum/PRM/gspan.h>

+ Collaboration diagram for gum::prm::GSpan< GUM_SCALAR >:

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...
 
MatchedInstancesmatches (const gspan::Pattern &p)
 Returns a mapping between patterns and the sequence of instance in the interface graph matching them. More...
 
const MatchedInstancesmatches (const gspan::Pattern &p) const
 Returns a mapping between patterns and the sequence of instance in the interface graph matching them. More...
 

Detailed Description

template<typename GUM_SCALAR>
class gum::prm::GSpan< GUM_SCALAR >

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().

Definition at line 56 of file DFSTree.h.

Member Typedef Documentation

◆ MatchedInstances

template<typename GUM_SCALAR >
typedef Set< Sequence< PRMInstance< GUM_SCALAR >* >* > gum::prm::GSpan< GUM_SCALAR >::MatchedInstances

Code alias.

Definition at line 169 of file gspan.h.

Constructor & Destructor Documentation

◆ GSpan()

template<typename GUM_SCALAR >
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.

Parameters
prmThe PRM<GUM_SCALAR> used by this class.
sysThe PRMSystem<GUM_SCALAR> on which this class searches for patterns.
strategyThe search strategy used for pattern mining, the default strategy is gspan::FrequenceSearch.

Definition at line 344 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

346  :
347  _graph_(new gspan::InterfaceGraph< GUM_SCALAR >(sys)),
348  _tree_(*_graph_, strategy), _depth_stop_(INT_MAX) {
349  GUM_CONSTRUCTOR(GSpan);
350  }
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition: gspan_tpl.h:344
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
Size _depth_stop_
The max depth allowed for the DSF tree.
Definition: gspan.h:221
+ Here is the call graph for this function:

◆ ~GSpan()

template<typename GUM_SCALAR >
INLINE gum::prm::GSpan< GUM_SCALAR >::~GSpan ( )

Destructor.

Definition at line 353 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

353  {
354  GUM_DESTRUCTOR(GSpan);
355 
356  for (const auto& elt: _matched_instances_)
357  delete elt.second;
358 
359  delete _graph_;
360  }
HashTable< gspan::Pattern *, MatchedInstances *> _matched_instances_
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:237
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition: gspan_tpl.h:344
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

Member Function Documentation

◆ _cost_func_()

template<typename GUM_SCALAR >
INLINE Idx gum::prm::GSpan< GUM_SCALAR >::_cost_func_ ( Size  interface_size,
Size  frequency 
)
private

Returns the cost with respect to an interface size and its frequency.

Parameters
interface_sizeThe size of all output nodes of a pattern.
frequencyThe frequency of the pattern in the current interface graph.
Returns
the cost with respect to an interface size and its frequency.

Definition at line 383 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

383  {
384  return Idx(interface_size * frequency);
385  }
Size Idx
Type for indexes.
Definition: types.h:52
+ Here is the call graph for this function:

◆ _isEdgeEligible_()

template<typename GUM_SCALAR >
INLINE bool gum::prm::GSpan< GUM_SCALAR >::_isEdgeEligible_ ( typename gspan::EdgeData< GUM_SCALAR > *  e)
private

Returns true if e is an eligible root edge.

Parameters
eAn EdgeData<GUM_SCALAR>.
Returns
true if e is an eligible root edge.

Definition at line 420 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

420  {
421  return (_graph_->edges(e->l).size() >= 2) && (_graph_->nodes(e->l_u).size() >= 2)
422  && (_graph_->nodes(e->l_v).size() >= 2);
423  }
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

◆ _sortNodesAndEdges_()

template<typename GUM_SCALAR >
void gum::prm::GSpan< GUM_SCALAR >::_sortNodesAndEdges_ ( )
private

Sort the nodes and edges of graph.

Definition at line 57 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

57  {
58  for (auto iter = _graph_->labels().begin(); iter != _graph_->labels().end(); ++iter) {
59  try {
60  if (_graph_->nodes(iter.second()).size() >= 2) {
61  _cost_.insert(
62  iter.second(),
63  _cost_func_(iter.second()->tree_width, _graph_->nodes(iter.second()).size()));
64  _nodes_.push_back(const_cast< gspan::LabelData* >(iter.second()));
65  }
66  } catch (NotFound&) {
67  // It's a label over edges
68  if (_isEdgeEligible_(*(_graph_->edges(iter.second()).begin()))) {
69  _cost_.insert(
70  iter.second(),
71  _cost_func_(iter.second()->tree_width, _graph_->edges(iter.second()).size()));
72  _edges_.push_back(iter.second());
73  }
74  }
75  }
76 
77  Bijection< Idx, gspan::LabelData* >* new_labels = new Bijection< Idx, gspan::LabelData* >();
78  GSpan< GUM_SCALAR >::LabelSort my_sort(this);
79  std::sort(_nodes_.begin(), _nodes_.end(), my_sort);
80  std::sort(_edges_.begin(), _edges_.end(), my_sort);
81  Size idx = 0;
82 
83  for (auto iter = _nodes_.begin(); iter != _nodes_.end(); ++iter) {
84  (*iter)->id = ++idx;
85  new_labels->insert(idx, *iter);
86  }
87 
88  for (auto iter = _edges_.begin(); iter != _edges_.end(); ++iter) {
89  (*iter)->id = ++idx;
90  new_labels->insert(idx, *iter);
91  _tree_.addRoot(**iter);
92  }
93 
94  delete _graph_->_labels_;
95  _graph_->_labels_ = new_labels;
96  }
Size _cost_func_(Size interface_size, Size frequency)
Returns the cost with respect to an interface size and its frequency.
Definition: gspan_tpl.h:383
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
bool _isEdgeEligible_(typename gspan::EdgeData< GUM_SCALAR > *e)
Returns true if e is an eligible root edge.
Definition: gspan_tpl.h:420
std::vector< gspan::LabelData *> _edges_
The vector of edges in graph, in decreasing order of interest.
Definition: gspan.h:230
std::vector< gspan::LabelData *> _nodes_
The vector of nodes in graph, in decreasing order of interest.
Definition: gspan.h:227
HashTable< gspan::LabelData *, Idx > _cost_
Mapping between labels and their cost.
Definition: gspan.h:233
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:47
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

◆ _sortPatterns_()

template<typename GUM_SCALAR >
void gum::prm::GSpan< GUM_SCALAR >::_sortPatterns_ ( )
private

Sort the patterns and compute their respective costs.

Definition at line 219 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

219  {
220  // First we put all the patterns in _patterns_.
221  std::vector< NodeId > stack;
222 
223  for (std::list< NodeId >::reverse_iterator root = tree().roots().rbegin();
224  root != tree().roots().rend();
225  ++root)
226  stack.push_back(*root);
227 
228  NodeId id = 0;
229  std::list< NodeId >* children = nullptr;
230 
231  while (!stack.empty()) {
232  id = stack.back();
233  stack.pop_back();
234  _patterns_.push_back(&(tree().pattern(id)));
235  children = &(tree().children(tree().pattern(id)));
236 
237  for (std::list< NodeId >::reverse_iterator child = children->rbegin();
238  child != children->rend();
239  ++child)
240  stack.push_back(*child);
241  }
242 
243  if (!_patterns_.empty()) {
244  // We sort _patterns_.
245  GSpan< GUM_SCALAR >::PatternSort my_sort(this);
246  std::sort(_patterns_.begin(), _patterns_.end(), my_sort);
247  // Now we need to find all the matches we can, using _patterns_.
248  // We start by the best Pattern and add it's maximal independent set to
249  // _chosen_
252  Sequence< PRMInstance< GUM_SCALAR >* >* match = nullptr;
253 
254  for (const auto node: tree().max_indep_set(*(_patterns_.front()))) {
255  match = &(tree().iso_map(*(_patterns_.front()), node));
256 
257  for (const auto i: *match)
258  _chosen_.insert(i);
259 
260  matches->insert(match);
261  }
262 
263  _matched_instances_.insert(_patterns_.front(), matches);
264  // Now we see what kind of pattern we can still use
265  bool found;
266  UndiGraph* iso_graph = nullptr;
267 
268  for (auto patt = _patterns_.begin() + 1; patt != _patterns_.end(); ++patt) {
269  UndiGraph reduced_iso_graph;
270  std::vector< NodeId > degree_list;
271  iso_graph = &(tree().iso_graph(**patt));
272 
273  for (const auto node: iso_graph->nodes()) {
274  found = false;
275  match = &(tree().iso_map(**patt, node));
276 
277  for (const auto i: *match)
278  if (_chosen_.exists(i)) {
279  found = true;
280  break;
281  }
282 
283  if (!found) {
284  // We add the pattern to the reduced isomorphism graph to compute
285  // the
286  // max independent set
287  // over the remaining matches
288  reduced_iso_graph.addNodeWithId(node);
289 
290  for (const auto iso: reduced_iso_graph.nodes())
291  if (iso_graph->existsEdge(node, iso)) reduced_iso_graph.addEdge(node, iso);
292 
293  degree_list.push_back(node);
294  }
295  }
296 
297  // We create a new set to hold all the chosen matches of patt
299  // We can compute the max independent set and the matches belonging to
300  // it
301  typename gspan::DFSTree< GUM_SCALAR >::NeighborDegreeSort my_sort(reduced_iso_graph);
302  std::sort(degree_list.begin(), degree_list.end(), my_sort);
303  Set< NodeId > removed;
304 
305  for (const auto node: degree_list)
306  if (!removed.exists(node)) {
307  // First we update removed to follow the max independent set
308  // algorithm
309  removed.insert(node);
310 
311  for (const auto neighbor: reduced_iso_graph.neighbours(node))
312  removed.insert(neighbor);
313 
314  // Second we update match and matches to keep track of the current
315  // match
316  match = &(tree().iso_map(**patt, node));
317  matches->insert(match);
318 
319  for (const auto elt: *match)
320  _chosen_.insert(elt);
321  }
322 
323  _matched_instances_.insert(*patt, matches);
324  }
325 
326  // // We remove patterns with 0 matches
327  std::vector< size_t > trash;
328 
329  for (size_t idx = 0; idx < _patterns_.size(); ++idx)
330  if (_matched_instances_[_patterns_[idx]]->size() < 2) trash.push_back(idx);
331 
332  while (trash.size()) {
333  delete _matched_instances_[_patterns_[trash.back()]];
334  _matched_instances_.erase(_patterns_[trash.back()]);
335  // delete _patterns_[trash.back()];
336  _patterns_[trash.back()] = _patterns_.back();
337  _patterns_.pop_back();
338  trash.pop_back();
339  }
340  }
341  }
HashTable< gspan::Pattern *, MatchedInstances *> _matched_instances_
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:237
Set< Sequence< PRMInstance< GUM_SCALAR > *> *> MatchedInstances
Code alias.
Definition: gspan.h:169
Set< PRMInstance< GUM_SCALAR > *> _chosen_
Contains all instance which belongs to a discovered and used pattern.
Definition: gspan.h:240
std::vector< gspan::Pattern *> _patterns_
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:224
gspan::DFSTree< GUM_SCALAR > & tree()
Returns the DFSTree used to discover new patters.
Definition: gspan_tpl.h:373
MatchedInstances & matches(const gspan::Pattern &p)
Returns a mapping between patterns and the sequence of instance in the interface graph matching them...
Definition: gspan_tpl.h:399
Size NodeId
Type for node ids.
Definition: graphElements.h:97
void insert(const Key &k)
Inserts a new element into the set.
Definition: set_tpl.h:606
+ Here is the call graph for this function:

◆ _subgraph_mining_()

template<typename GUM_SCALAR >
void gum::prm::GSpan< GUM_SCALAR >::_subgraph_mining_ ( gspan::InterfaceGraph< GUM_SCALAR > &  graph,
gspan::Pattern p 
)
private

Discovers new patterns by developing p.

Parameters
graphThe interface graph used in this discovery process.
pThe pattern used as a base for discovery.

Definition at line 99 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

100  {
101  std::vector< gspan::Pattern* > stack;
102  stack.push_back(&pat);
103  // Pointers used in the following while
104  gspan::Pattern* p = nullptr;
105  HashTable< std::string, gspan::EdgeGrowth< GUM_SCALAR >* >* edge_count = nullptr;
106  gspan::EdgeGrowth< GUM_SCALAR >* edge_growth = nullptr;
107  Sequence< PRMInstance< GUM_SCALAR >* >* seq = nullptr;
108  PRMInstance< GUM_SCALAR >* current = nullptr;
109  PRMInstance< GUM_SCALAR >* neighbor = nullptr;
110 
111  // Neighbor_id is the neighbor's id in the interface graph and
112  // neighbor_node
113  // is its id in the rightmost path in the case of a backward edge growth
114  NodeId current_id = 0;
115  NodeId neighbor_node = 0;
116  gspan::LabelData* neighbor_label = 0;
117 
118  typename gspan::EdgeData< GUM_SCALAR >* edge_data = nullptr;
119 
120  size_t idx;
121  const std::list< NodeId >* children = 0;
122 
123  while (!stack.empty()) {
124  // Getting next pattern
125  p = stack.back();
126  stack.pop_back();
127 
128  if (p->code().codes.size() < _depth_stop_) {
129  // We need the rightmost path of p
130  std::list< NodeId > r_path;
131  p->rightmostPath(r_path);
132  // Mapping used to count each possible child of p, the position in the
133  // vector
134  // matches the one in the rightmost path
135  std::vector< HashTable< std::string, gspan::EdgeGrowth< GUM_SCALAR >* >* > count_vector;
136 
137  for (size_t i = 0; i < r_path.size(); ++i)
138  count_vector.push_back(
139  new HashTable< std::string, gspan::EdgeGrowth< GUM_SCALAR >* >());
140 
141  // For each subgraph represented by p, we look for a valid edge growth
142  // for
143  // each instance match of p in its isomorphism graph.
144  for (const auto iso_node: _tree_.iso_graph(*p).nodes()) {
145  seq = &(_tree_.iso_map(*p, iso_node));
146  idx = 0;
147 
148  for (const auto node: r_path) {
149  edge_count = count_vector[idx];
150  // Retrieving the equivalent instance in the current match
151  current = seq->atPos((Idx)(node - 1));
152  current_id = ig.id(current);
153  // Checking for edges not in p
154 
155  for (const auto neighbor_id: ig.graph().neighbours(current_id)) {
156  neighbor = ig.node(neighbor_id).n;
157 
158  // We want a forward edge in any case or a backward edge if
159  // current
160  // is the rightmost vertex
161  if ((!seq->exists(neighbor)) || (node == r_path.back())) {
162  // Things we need to know: the LabelData data of the neighbour
163  // and,
164  // if it's a backward edge, its node id in the rightmost path
165  edge_data = &(ig.edge(current_id, neighbor_id));
166  neighbor_label = (neighbor == edge_data->u) ? edge_data->l_u : edge_data->l_v;
167  neighbor_node = (seq->exists(neighbor)) ? seq->pos(neighbor) + 1 : 0;
168  // Adding the edge growth to the edge_growth hashtable
169  gspan::EdgeGrowth< GUM_SCALAR > temp_growth(node,
170  edge_data->l,
171  neighbor_label,
172  neighbor_node);
173 
174  try {
175  edge_growth = (*edge_count)[temp_growth.toString()];
176  edge_growth->insert(current, neighbor);
177  } catch (NotFound&) {
178  edge_growth = new gspan::EdgeGrowth< GUM_SCALAR >(node,
179  edge_data->l,
180  neighbor_label,
181  neighbor_node);
182  edge_growth->insert(current, neighbor);
183  edge_count->insert(edge_growth->toString(), edge_growth);
184  }
185  }
186  }
187  }
188  }
189 
190  // Removing any infrequent child
191  for (size_t node = 0; node < count_vector.size(); ++node) {
192  edge_count = count_vector[node];
193 
194  for (const auto& elt: *edge_count) {
195  try {
196  _tree_.growPattern(*p, *elt.second, 2);
197  } catch (OperationNotAllowed&) {
198  // The child was not minimal or was not worth considering
199  }
200 
201  delete elt.second;
202  }
203 
204  delete edge_count;
205  }
206 
207  // Calling _subgraph_mining_ over children of p
208  children = &(_tree_.children(*p));
209 
210  for (std::list< NodeId >::const_reverse_iterator child = children->rbegin();
211  child != children->rend();
212  ++child)
213  stack.push_back(&(_tree_.pattern(*child)));
214  }
215  }
216  }
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Size _depth_stop_
The max depth allowed for the DSF tree.
Definition: gspan.h:221
+ Here is the call graph for this function:

◆ discoverPatterns()

template<typename GUM_SCALAR >
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 35 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

35  {
36  Timer t;
38  gspan::InterfaceGraph< GUM_SCALAR > graph(*_graph_);
39 
40  for (auto root = _tree_.roots().begin(); root != _tree_.roots().end(); ++root) {
41  if (_tree_.strategy().accept_root(&(_tree_.pattern(*root)))) {
42  gspan::Pattern& p = _tree_.pattern(*root);
43  _subgraph_mining_(graph, p);
44 
45  for (const auto node: _tree_.iso_graph(p).nodes()) {
46  PRMInstance< GUM_SCALAR >* u = _tree_.iso_map(p, node).atPos(0);
47  PRMInstance< GUM_SCALAR >* v = _tree_.iso_map(p, node).atPos(1);
48  graph.graph().eraseEdge(Edge(graph.id(u), graph.id(v)));
49  }
50  }
51  }
52 
54  }
void _sortPatterns_()
Sort the patterns and compute their respective costs.
Definition: gspan_tpl.h:219
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
void _subgraph_mining_(gspan::InterfaceGraph< GUM_SCALAR > &graph, gspan::Pattern &p)
Discovers new patterns by developing p.
Definition: gspan_tpl.h:99
void _sortNodesAndEdges_()
Sort the nodes and edges of graph.
Definition: gspan_tpl.h:57
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

◆ getMaxDFSDepth()

template<typename GUM_SCALAR >
INLINE Size gum::prm::GSpan< GUM_SCALAR >::getMaxDFSDepth ( ) const

Returns the maximal depth of the DFSTree used to discover new patterns.

Returns
the maximal depth of the DFSTree used to discover new patterns.

Definition at line 363 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

363  {
364  return _depth_stop_;
365  }
Size _depth_stop_
The max depth allowed for the DSF tree.
Definition: gspan.h:221
+ Here is the call graph for this function:

◆ interfaceGraph() [1/2]

template<typename GUM_SCALAR >
INLINE gspan::InterfaceGraph< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::interfaceGraph ( )

Returns the InterfaceGraph used by this.

Returns
the InterfaceGraph used by this.

Definition at line 410 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

410  {
411  return *_graph_;
412  }
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

◆ interfaceGraph() [2/2]

template<typename GUM_SCALAR >
INLINE const gspan::InterfaceGraph< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::interfaceGraph ( ) const

Returns the InterfaceGraph used by this.

Returns
the InterfaceGraph used by this.

Definition at line 415 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

415  {
416  return *_graph_;
417  }
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition: gspan.h:215
+ Here is the call graph for this function:

◆ matches() [1/2]

template<typename GUM_SCALAR >
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.

Returns
a mapping between patterns and the sequence of instance in the interface graph matching them.

Definition at line 399 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

399  {
400  return *(_matched_instances_[const_cast< gspan::Pattern* >(&p)]);
401  }
HashTable< gspan::Pattern *, MatchedInstances *> _matched_instances_
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:237
+ Here is the call graph for this function:

◆ matches() [2/2]

template<typename GUM_SCALAR >
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.

Returns
a mapping between patterns and the sequence of instance in the interface graph matching them.

Definition at line 405 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

405  {
406  return *(_matched_instances_[const_cast< gspan::Pattern* >(&p)]);
407  }
HashTable< gspan::Pattern *, MatchedInstances *> _matched_instances_
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:237
+ Here is the call graph for this function:

◆ patterns() [1/2]

template<typename GUM_SCALAR >
INLINE std::vector< gspan::Pattern *> & gum::prm::GSpan< GUM_SCALAR >::patterns ( )

Returns the Pattern mined by this class in a decreasing order of interest.

Returns
the Pattern mined by this class in a decreasing order of interest.

Definition at line 388 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

388  {
389  return _patterns_;
390  }
std::vector< gspan::Pattern *> _patterns_
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:224
+ Here is the call graph for this function:

◆ patterns() [2/2]

template<typename GUM_SCALAR >
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.

Returns
the Pattern mined by this class in a decreasing order of interest.

Definition at line 393 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

393  {
394  return _patterns_;
395  }
std::vector< gspan::Pattern *> _patterns_
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:224
+ Here is the call graph for this function:

◆ setMaxDFSDepth()

template<typename GUM_SCALAR >
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.

Parameters
depthThe new maximal DFSTree depth.

Definition at line 368 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

368  {
369  _depth_stop_ = depth;
370  }
Size _depth_stop_
The max depth allowed for the DSF tree.
Definition: gspan.h:221
+ Here is the call graph for this function:

◆ tree() [1/2]

template<typename GUM_SCALAR >
INLINE gspan::DFSTree< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::tree ( )

Returns the DFSTree used to discover new patters.

Returns
the DFSTree used to discover new patters.

Definition at line 373 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

373  {
374  return _tree_;
375  }
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
+ Here is the call graph for this function:

◆ tree() [2/2]

template<typename GUM_SCALAR >
INLINE const gspan::DFSTree< GUM_SCALAR > & gum::prm::GSpan< GUM_SCALAR >::tree ( ) const

Returns the DFSTree used to discover new patters.

Returns
the DFSTree used to discover new patters.

Definition at line 378 of file gspan_tpl.h.

References gum::prm::ParamScopeData< GUM_SCALAR >::ParamScopeData().

378  {
379  return _tree_;
380  }
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition: gspan.h:218
+ Here is the call graph for this function:

Member Data Documentation

◆ _chosen_

template<typename GUM_SCALAR >
Set< PRMInstance< GUM_SCALAR >* > gum::prm::GSpan< GUM_SCALAR >::_chosen_
private

Contains all instance which belongs to a discovered and used pattern.

Definition at line 240 of file gspan.h.

◆ _cost_

template<typename GUM_SCALAR >
HashTable< gspan::LabelData*, Idx > gum::prm::GSpan< GUM_SCALAR >::_cost_
private

Mapping between labels and their cost.

Definition at line 233 of file gspan.h.

◆ _depth_stop_

template<typename GUM_SCALAR >
Size gum::prm::GSpan< GUM_SCALAR >::_depth_stop_
private

The max depth allowed for the DSF tree.

Definition at line 221 of file gspan.h.

◆ _edges_

template<typename GUM_SCALAR >
std::vector< gspan::LabelData* > gum::prm::GSpan< GUM_SCALAR >::_edges_
private

The vector of edges in graph, in decreasing order of interest.

Definition at line 230 of file gspan.h.

◆ _graph_

template<typename GUM_SCALAR >
gspan::InterfaceGraph< GUM_SCALAR >* gum::prm::GSpan< GUM_SCALAR >::_graph_
private

The interface graph used by this class.

Definition at line 215 of file gspan.h.

◆ _matched_instances_

template<typename GUM_SCALAR >
HashTable< gspan::Pattern*, MatchedInstances* > gum::prm::GSpan< GUM_SCALAR >::_matched_instances_
private

Mapping between a pattern and the multiset of instances matched to it.

Definition at line 237 of file gspan.h.

◆ _nodes_

template<typename GUM_SCALAR >
std::vector< gspan::LabelData* > gum::prm::GSpan< GUM_SCALAR >::_nodes_
private

The vector of nodes in graph, in decreasing order of interest.

Definition at line 227 of file gspan.h.

◆ _patterns_

template<typename GUM_SCALAR >
std::vector< gspan::Pattern* > gum::prm::GSpan< GUM_SCALAR >::_patterns_
private

The vector of discovered patters, in decreasing order of interest.

Definition at line 224 of file gspan.h.

◆ _tree_

template<typename GUM_SCALAR >
gspan::DFSTree< GUM_SCALAR > gum::prm::GSpan< GUM_SCALAR >::_tree_
private

The DFSTree used to discover new patters.

Definition at line 218 of file gspan.h.


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