aGrUM  0.16.0
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 57 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 170 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 355 of file gspan_tpl.h.

357  :
358  __graph(new gspan::InterfaceGraph< GUM_SCALAR >(sys)),
359  __tree(*__graph, strategy), __depth_stop(INT_MAX) {
360  GUM_CONSTRUCTOR(GSpan);
361  }
Size __depth_stop
The max depth allowed for the DSF tree.
Definition: gspan.h:222
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition: gspan_tpl.h:355

◆ ~GSpan()

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

364  {
365  GUM_DESTRUCTOR(GSpan);
366 
367  for (const auto& elt : __matched_instances)
368  delete elt.second;
369 
370  delete __graph;
371  }
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition: gspan_tpl.h:355
HashTable< gspan::Pattern *, MatchedInstances *> __matched_instances
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:238

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. TODO replace this by a class to enable different cost policies.

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 394 of file gspan_tpl.h.

395  {
396  return Idx(interface_size * frequency);
397  }
Size Idx
Type for indexes.
Definition: types.h:53

◆ __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 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.

436  {
437  return (__graph->edges(e->l).size() >= 2)
438  && (__graph->nodes(e->l_u).size() >= 2)
439  && (__graph->nodes(e->l_v).size() >= 2);
440  }
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216

◆ __sortNodesAndEdges()

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

Sort the nodes and edges of __graph.

Definition at line 59 of file gspan_tpl.h.

References gum::BijectionImplementation< T1, T2, Alloc, std::is_scalar< T1 >::value &&std::is_scalar< T2 >::value >::insert().

59  {
60  for (auto iter = __graph->labels().begin(); iter != __graph->labels().end();
61  ++iter) {
62  try {
63  if (__graph->nodes(iter.second()).size() >= 2) {
64  __cost.insert(iter.second(),
65  __cost_func(iter.second()->tree_width,
66  __graph->nodes(iter.second()).size()));
67  __nodes.push_back(const_cast< gspan::LabelData* >(iter.second()));
68  }
69  } catch (NotFound&) {
70  // It's a label over edges
71  if (__isEdgeEligible(*(__graph->edges(iter.second()).begin()))) {
72  __cost.insert(iter.second(),
73  __cost_func(iter.second()->tree_width,
74  __graph->edges(iter.second()).size()));
75  __edges.push_back(iter.second());
76  }
77  }
78  }
79 
80  Bijection< Idx, gspan::LabelData* >* new_labels =
81  new Bijection< Idx, gspan::LabelData* >();
82  GSpan< GUM_SCALAR >::LabelSort my_sort(this);
83  std::sort(__nodes.begin(), __nodes.end(), my_sort);
84  std::sort(__edges.begin(), __edges.end(), my_sort);
85  Size idx = 0;
86 
87  for (auto iter = __nodes.begin(); iter != __nodes.end(); ++iter) {
88  (*iter)->id = ++idx;
89  new_labels->insert(idx, *iter);
90  }
91 
92  for (auto iter = __edges.begin(); iter != __edges.end(); ++iter) {
93  (*iter)->id = ++idx;
94  new_labels->insert(idx, *iter);
95  __tree.addRoot(**iter);
96  }
97 
98  delete __graph->__labels;
99  __graph->__labels = new_labels;
100  }
bool __isEdgeEligible(typename gspan::EdgeData< GUM_SCALAR > *e)
Returns true if e is an eligible root edge.
Definition: gspan_tpl.h:436
std::vector< gspan::LabelData *> __nodes
The vector of nodes in __graph, in decreasing order of interest.
Definition: gspan.h:228
HashTable< gspan::LabelData *, Idx > __cost
Mapping between labels and their cost.
Definition: gspan.h:234
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
std::vector< gspan::LabelData *> __edges
The vector of edges in __graph, in decreasing order of interest.
Definition: gspan.h:231
Size __cost_func(Size interface_size, Size frequency)
Returns the cost with respect to an interface size and its frequency. TODO replace this by a class to...
Definition: gspan_tpl.h:394
+ 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 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().

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

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

References gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::graph(), and gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::id().

36  {
37  Timer t;
39  gspan::InterfaceGraph< GUM_SCALAR > graph(*__graph);
40 
41  for (auto root = __tree.roots().begin(); root != __tree.roots().end();
42  ++root) {
43  if (__tree.strategy().accept_root(&(__tree.pattern(*root)))) {
44  gspan::Pattern& p = __tree.pattern(*root);
45  __subgraph_mining(graph, p);
46 
47  for (const auto node : __tree.iso_graph(p).nodes()) {
48  PRMInstance< GUM_SCALAR >* u = __tree.iso_map(p, node).atPos(0);
49  PRMInstance< GUM_SCALAR >* v = __tree.iso_map(p, node).atPos(1);
50  graph.graph().eraseEdge(Edge(graph.id(u), graph.id(v)));
51  }
52  }
53  }
54 
56  }
void __subgraph_mining(gspan::InterfaceGraph< GUM_SCALAR > &graph, gspan::Pattern &p)
Discovers new patterns by developing p.
Definition: gspan_tpl.h:103
void __sortPatterns()
Sort the patterns and compute their respective costs.
Definition: gspan_tpl.h:225
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216
void __sortNodesAndEdges()
Sort the nodes and edges of __graph.
Definition: gspan_tpl.h:59
+ 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 374 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__depth_stop.

374  {
375  return __depth_stop;
376  }
Size __depth_stop
The max depth allowed for the DSF tree.
Definition: gspan.h:222

◆ 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 424 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__graph.

424  {
425  return *__graph;
426  }
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216

◆ 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 430 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__graph.

430  {
431  return *__graph;
432  }
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216

◆ 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 412 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__matched_instances.

412  {
413  return *(__matched_instances[const_cast< gspan::Pattern* >(&p)]);
414  }
HashTable< gspan::Pattern *, MatchedInstances *> __matched_instances
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:238

◆ 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 418 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__matched_instances.

418  {
419  return *(__matched_instances[const_cast< gspan::Pattern* >(&p)]);
420  }
HashTable< gspan::Pattern *, MatchedInstances *> __matched_instances
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:238

◆ 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 400 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__patterns.

400  {
401  return __patterns;
402  }
std::vector< gspan::Pattern *> __patterns
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:225

◆ 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 406 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__patterns.

406  {
407  return __patterns;
408  }
std::vector< gspan::Pattern *> __patterns
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:225

◆ 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 379 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__depth_stop.

379  {
380  __depth_stop = depth;
381  }
Size __depth_stop
The max depth allowed for the DSF tree.
Definition: gspan.h:222

◆ 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 384 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__tree.

Referenced by gum::prm::GSpan< GUM_SCALAR >::PatternSort::operator()().

384  {
385  return __tree;
386  }
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219
+ Here is the caller 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 389 of file gspan_tpl.h.

References gum::prm::GSpan< GUM_SCALAR >::__tree.

389  {
390  return __tree;
391  }
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219

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 241 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 234 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 222 of file gspan.h.

Referenced by gum::prm::GSpan< GUM_SCALAR >::getMaxDFSDepth(), and gum::prm::GSpan< GUM_SCALAR >::setMaxDFSDepth().

◆ __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 231 of file gspan.h.

◆ __graph

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

◆ __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 238 of file gspan.h.

Referenced by gum::prm::GSpan< GUM_SCALAR >::matches(), and gum::prm::GSpan< GUM_SCALAR >::~GSpan().

◆ __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 228 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 225 of file gspan.h.

Referenced by gum::prm::GSpan< GUM_SCALAR >::patterns().

◆ __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 219 of file gspan.h.

Referenced by gum::prm::GSpan< GUM_SCALAR >::LabelSort::operator()(), and gum::prm::GSpan< GUM_SCALAR >::tree().


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