aGrUM 3.2.0
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 >:
[legend]

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

Public Member Functions

Constructors & destructor.
 GSpan (const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
 Default constructor.
 ~GSpan ()
 Destructor.
Getters and setters.
Size getMaxDFSDepth () const
 Returns the maximal depth of the DFSTree used to discover new patterns.
void setMaxDFSDepth (Size depth)
 Defines the maximal depth of the DFSTree used by this class to discover new patterns.
gspan::DFSTree< GUM_SCALAR > & tree ()
 Returns the DFSTree used to discover new patters.
const gspan::DFSTree< GUM_SCALAR > & tree () const
 Returns the DFSTree used to discover new patters.
gspan::InterfaceGraph< GUM_SCALAR > & interfaceGraph ()
 Returns the InterfaceGraph used by this.
const gspan::InterfaceGraph< GUM_SCALAR > & interfaceGraph () const
 Returns the InterfaceGraph used by this.

Private Member Functions

Private Methods
void _sortNodesAndEdges_ ()
 Sort the nodes and edges of graph.
void _subgraph_mining_ (gspan::InterfaceGraph< GUM_SCALAR > &graph, gspan::Pattern &p)
 Discovers new patterns by developing p.
Size _cost_func_ (Size interface_size, Size frequency)
 Returns the cost with respect to an interface size and its frequency.
void _sortPatterns_ ()
 Sort the patterns and compute their respective costs.
bool _isEdgeEligible_ (typename gspan::EdgeData< GUM_SCALAR > *e)
 Returns true if e is an eligible root edge.

Private Attributes

Private Members.
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
 The interface graph used by this class.
gspan::DFSTree< GUM_SCALAR > _tree_
 The DFSTree used to discover new patters.
Size _depth_stop_
 The max depth allowed for the DSF tree.
std::vector< gspan::Pattern * > _patterns_
 The vector of discovered patters, in decreasing order of interest.
std::vector< gspan::LabelData * > _nodes_
 The vector of nodes in graph, in decreasing order of interest.
std::vector< gspan::LabelData * > _edges_
 The vector of edges in graph, in decreasing order of interest.
HashTable< gspan::LabelData *, Idx > _cost_
 Mapping between labels and their cost.
HashTable< gspan::Pattern *, MatchedInstances * > _matched_instances_
 Mapping between a pattern and the multiset of instances matched to it.
Set< PRMInstance< GUM_SCALAR > * > _chosen_
 Contains all instance which belongs to a discovered and used pattern.

Pattern discovery methods.

using MatchedInstances = Set< Sequence< PRMInstance< GUM_SCALAR >* >* >
 Code alias.
void discoverPatterns ()
 This will methods will discover repeated patterns in the PRMSystem<GUM_SCALAR> assigned to this class.
std::vector< gspan::Pattern * > & patterns ()
 Returns the Pattern mined by this class in a decreasing order of interest.
const std::vector< gspan::Pattern * > & patterns () const
 Returns the Pattern mined by this class in a decreasing order of interest.
MatchedInstances & matches (const gspan::Pattern &p)
 Returns a mapping between patterns and the sequence of instance in the interface graph matching them.
const MatchedInstances & matches (const gspan::Pattern &p) const
 Returns a mapping between patterns and the sequence of instance in the interface graph matching them.

Detailed Description

template<GUM_Numeric 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 86 of file gspan.h.

Member Typedef Documentation

◆ MatchedInstances

template<GUM_Numeric GUM_SCALAR>
using gum::prm::GSpan< GUM_SCALAR >::MatchedInstances = Set< Sequence< PRMInstance< GUM_SCALAR >* >* >

Code alias.

Definition at line 185 of file gspan.h.

Constructor & Destructor Documentation

◆ GSpan()

template<GUM_Numeric GUM_SCALAR>
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 366 of file gspan_tpl.h.

368 :
372 }
This class discovers pattern in a PRM<GUM_SCALAR>'s PRMSystem<GUM_SCALAR> to speed up structured infe...
Definition gspan.h:86
gspan::InterfaceGraph< GUM_SCALAR > * _graph_
The interface graph used by this class.
Definition gspan.h:232
gspan::DFSTree< GUM_SCALAR > _tree_
The DFSTree used to discover new patters.
Definition gspan.h:235
Size _depth_stop_
The max depth allowed for the DSF tree.
Definition gspan.h:238
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition gspan_tpl.h:366

References GSpan(), _depth_stop_, _graph_, and _tree_.

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~GSpan()

template<GUM_Numeric GUM_SCALAR>
gum::prm::GSpan< GUM_SCALAR >::~GSpan ( )

Destructor.

Definition at line 375 of file gspan_tpl.h.

375 {
377
378 for (const auto& elt: _matched_instances_)
379 delete elt.second;
380
381 delete _graph_;
382 }
HashTable< gspan::Pattern *, MatchedInstances * > _matched_instances_
Mapping between a pattern and the multiset of instances matched to it.
Definition gspan.h:254

References GSpan(), _graph_, and _matched_instances_.

Here is the call graph for this function:

Member Function Documentation

◆ _cost_func_()

template<GUM_Numeric GUM_SCALAR>
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 405 of file gspan_tpl.h.

405 {
406 return Idx(interface_size * frequency);
407 }

Referenced by _sortNodesAndEdges_().

Here is the caller graph for this function:

◆ _isEdgeEligible_()

template<GUM_Numeric GUM_SCALAR>
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 442 of file gspan_tpl.h.

442 {
443 return (_graph_->edges(e->l).size() >= 2) && (_graph_->nodes(e->l_u).size() >= 2)
444 && (_graph_->nodes(e->l_v).size() >= 2);
445 }

References _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.

Referenced by _sortNodesAndEdges_().

Here is the caller graph for this function:

◆ _sortNodesAndEdges_()

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

Sort the nodes and edges of graph.

Definition at line 79 of file gspan_tpl.h.

79 {
80 for (auto iter = _graph_->labels().begin(); iter != _graph_->labels().end(); ++iter) {
81 try {
82 if (_graph_->nodes(iter.second()).size() >= 2) {
83 _cost_.insert(
84 iter.second(),
85 _cost_func_(iter.second()->tree_width, _graph_->nodes(iter.second()).size()));
86 _nodes_.push_back(const_cast< gspan::LabelData* >(iter.second()));
87 }
88 } catch (NotFound const&) {
89 // It's a label over edges
90 if (_isEdgeEligible_(*(_graph_->edges(iter.second()).begin()))) {
91 _cost_.insert(
92 iter.second(),
93 _cost_func_(iter.second()->tree_width, _graph_->edges(iter.second()).size()));
94 _edges_.push_back(iter.second());
95 }
96 }
97 }
98
101 std::sort(_nodes_.begin(), _nodes_.end(), my_sort);
102 std::sort(_edges_.begin(), _edges_.end(), my_sort);
103 Size idx = 0;
104
105 for (auto iter = _nodes_.begin(); iter != _nodes_.end(); ++iter) {
106 (*iter)->id = ++idx;
107 new_labels->insert(idx, *iter);
108 }
109
110 for (auto iter = _edges_.begin(); iter != _edges_.end(); ++iter) {
111 (*iter)->id = ++idx;
112 new_labels->insert(idx, *iter);
113 _tree_.addRoot(**iter);
114 }
115
116 delete _graph_->_labels_;
117 _graph_->_labels_ = new_labels;
118 }
std::vector< gspan::LabelData * > _nodes_
The vector of nodes in graph, in decreasing order of interest.
Definition gspan.h:244
HashTable< gspan::LabelData *, Idx > _cost_
Mapping between labels and their cost.
Definition gspan.h:250
Size _cost_func_(Size interface_size, Size frequency)
Returns the cost with respect to an interface size and its frequency.
Definition gspan_tpl.h:405
std::vector< gspan::LabelData * > _edges_
The vector of edges in graph, in decreasing order of interest.
Definition gspan.h:247
bool _isEdgeEligible_(typename gspan::EdgeData< GUM_SCALAR > *e)
Returns true if e is an eligible root edge.
Definition gspan_tpl.h:442

References _cost_, _cost_func_(), _edges_, _graph_, _isEdgeEligible_(), _nodes_, _tree_, and gum::BijectionImplementation< T1, T2, Gen >::insert().

Referenced by discoverPatterns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _sortPatterns_()

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

Sort the patterns and compute their respective costs.

Definition at line 241 of file gspan_tpl.h.

241 {
242 // First we put all the patterns in _patterns_.
244
246 root != tree().roots().rend();
247 ++root)
248 stack.push_back(*root);
249
250 NodeId id = 0;
251 std::list< NodeId >* children = nullptr;
252
253 while (!stack.empty()) {
254 id = stack.back();
255 stack.pop_back();
256 _patterns_.push_back(&(tree().pattern(id)));
257 children = &(tree().children(tree().pattern(id)));
258
260 child != children->rend();
261 ++child)
262 stack.push_back(*child);
263 }
264
265 if (!_patterns_.empty()) {
266 // We sort _patterns_.
268 std::sort(_patterns_.begin(), _patterns_.end(), my_sort);
269 // Now we need to find all the matches we can, using _patterns_.
270 // We start by the best Pattern and add it's maximal independent set to
271 // _chosen_
275
276 for (const auto node: tree().max_indep_set(*(_patterns_.front()))) {
277 match = &(tree().iso_map(*(_patterns_.front()), node));
278
279 for (const auto i: *match)
280 _chosen_.insert(i);
281
282 matches->insert(match);
283 }
284
285 _matched_instances_.insert(_patterns_.front(), matches);
286 // Now we see what kind of pattern we can still use
287 bool found;
288 UndiGraph* iso_graph = nullptr;
289
290 for (auto patt = _patterns_.begin() + 1; patt != _patterns_.end(); ++patt) {
293 iso_graph = &(tree().iso_graph(**patt));
294
295 for (const auto node: iso_graph->nodes()) {
296 found = false;
297 match = &(tree().iso_map(**patt, node));
298
299 for (const auto i: *match)
300 if (_chosen_.exists(i)) {
301 found = true;
302 break;
303 }
304
305 if (!found) {
306 // We add the pattern to the reduced isomorphism graph to compute
307 // the
308 // max independent set
309 // over the remaining matches
310 reduced_iso_graph.addNodeWithId(node);
311
312 for (const auto iso: reduced_iso_graph.nodes())
313 if (iso_graph->existsEdge(node, iso)) reduced_iso_graph.addEdge(node, iso);
314
315 degree_list.push_back(node);
316 }
317 }
318
319 // We create a new set to hold all the chosen matches of patt
321 // We can compute the max independent set and the matches belonging to
322 // it
324 std::sort(degree_list.begin(), degree_list.end(), my_sort);
326
327 for (const auto node: degree_list)
328 if (!removed.exists(node)) {
329 // First we update removed to follow the max independent set
330 // algorithm
331 removed.insert(node);
332
333 for (const auto neighbor: reduced_iso_graph.neighbours(node))
334 removed.insert(neighbor);
335
336 // Second we update match and matches to keep track of the current
337 // match
338 match = &(tree().iso_map(**patt, node));
339 matches->insert(match);
340
341 for (const auto elt: *match)
342 _chosen_.insert(elt);
343 }
344
346 }
347
348 // // We remove patterns with 0 matches
350
351 for (size_t idx = 0; idx < _patterns_.size(); ++idx)
352 if (_matched_instances_[_patterns_[idx]]->size() < 2) trash.push_back(idx);
353
354 while (trash.size()) {
355 delete _matched_instances_[_patterns_[trash.back()]];
356 _matched_instances_.erase(_patterns_[trash.back()]);
357 // delete _patterns_[trash.back()];
358 _patterns_[trash.back()] = _patterns_.back();
359 _patterns_.pop_back();
360 trash.pop_back();
361 }
362 }
363 }
std::vector< gspan::Pattern * > _patterns_
The vector of discovered patters, in decreasing order of interest.
Definition gspan.h:241
gspan::DFSTree< GUM_SCALAR > & tree()
Returns the DFSTree used to discover new patters.
Definition gspan_tpl.h:395
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:421
Set< PRMInstance< GUM_SCALAR > * > _chosen_
Contains all instance which belongs to a discovered and used pattern.
Definition gspan.h:257
Set< Sequence< PRMInstance< GUM_SCALAR > * > * > MatchedInstances
Code alias.
Definition gspan.h:185

References _chosen_, _matched_instances_, _patterns_, gum::UndiGraph::addEdge(), gum::NodeGraphPart::addNodeWithId(), gum::Set< Key >::exists(), gum::EdgeGraphPart::existsEdge(), gum::SequenceImplementation< Key, Gen >::insert(), gum::Set< Key >::insert(), matches(), gum::EdgeGraphPart::neighbours(), gum::NodeGraphPart::nodes(), and tree().

Referenced by discoverPatterns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _subgraph_mining_()

template<GUM_Numeric 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 121 of file gspan_tpl.h.

122 {
124 stack.push_back(&pat);
125 // Pointers used in the following while
126 gspan::Pattern* p = nullptr;
132
133 // Neighbor_id is the neighbor's id in the interface graph and
134 // neighbor_node
135 // is its id in the rightmost path in the case of a backward edge growth
136 NodeId current_id = 0;
139
140 typename gspan::EdgeData< GUM_SCALAR >* edge_data = nullptr;
141
142 size_t idx;
143 const std::list< NodeId >* children = 0;
144
145 while (!stack.empty()) {
146 // Getting next pattern
147 p = stack.back();
148 stack.pop_back();
149
150 if (p->code().codes.size() < _depth_stop_) {
151 // We need the rightmost path of p
153 p->rightmostPath(r_path);
154 // Mapping used to count each possible child of p, the position in the
155 // vector
156 // matches the one in the rightmost path
158
159 for (size_t i = 0; i < r_path.size(); ++i)
160 count_vector.push_back(
162
163 // For each subgraph represented by p, we look for a valid edge growth
164 // for
165 // each instance match of p in its isomorphism graph.
166 for (const auto iso_node: _tree_.iso_graph(*p).nodes()) {
167 seq = &(_tree_.iso_map(*p, iso_node));
168 idx = 0;
169
170 for (const auto node: r_path) {
172 // Retrieving the equivalent instance in the current match
173 current = seq->atPos((Idx)(node - 1));
174 current_id = ig.id(current);
175 // Checking for edges not in p
176
177 for (const auto neighbor_id: ig.internalGraph().neighbours(current_id)) {
178 neighbor = ig.node(neighbor_id).n;
179
180 // We want a forward edge in any case or a backward edge if
181 // current
182 // is the rightmost vertex
183 if ((!seq->exists(neighbor)) || (node == r_path.back())) {
184 // Things we need to know: the LabelData data of the neighbour
185 // and,
186 // if it's a backward edge, its node id in the rightmost path
189 neighbor_node = (seq->exists(neighbor)) ? seq->pos(neighbor) + 1 : 0;
190 // Adding the edge growth to the edge_growth hashtable
192 edge_data->l,
195
196 if (edge_count->exists(temp_growth.toString())) {
197 edge_growth = (*edge_count)[temp_growth.toString()];
198 edge_growth->insert(current, neighbor);
199 } else {
201 edge_data->l,
204 edge_growth->insert(current, neighbor);
205 edge_count->insert(edge_growth->toString(), edge_growth);
206 }
207 }
208 }
209 }
210 }
211
212 // Removing any infrequent child
213 for (size_t node = 0; node < count_vector.size(); ++node) {
215
216 for (const auto& elt: *edge_count) {
217 try {
218 _tree_.growPattern(*p, *elt.second, 2);
219 } catch (OperationNotAllowed const&) {
220 // The child was not minimal or was not worth considering
221 }
222
223 delete elt.second;
224 }
225
226 delete edge_count;
227 }
228
229 // Calling _subgraph_mining_ over children of p
230 children = &(_tree_.children(*p));
231
233 child != children->rend();
234 ++child)
235 stack.push_back(&(_tree_.pattern(*child)));
236 }
237 }
238 }

References _depth_stop_, _tree_, gum::SequenceImplementation< Key, Gen >::atPos(), gum::prm::gspan::Pattern::code(), gum::prm::gspan::DFSCode::codes, gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::edge(), gum::HashTable< Key, Val >::exists(), gum::SequenceImplementation< Key, Gen >::exists(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::id(), gum::HashTable< Key, Val >::insert(), gum::prm::gspan::EdgeGrowth< GUM_SCALAR >::insert(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::internalGraph(), gum::prm::gspan::EdgeData< GUM_SCALAR >::l, gum::prm::gspan::EdgeData< GUM_SCALAR >::l_u, gum::prm::gspan::EdgeData< GUM_SCALAR >::l_v, gum::EdgeGraphPart::neighbours(), gum::prm::gspan::InterfaceGraph< GUM_SCALAR >::node(), gum::SequenceImplementation< Key, Gen >::pos(), gum::prm::gspan::Pattern::rightmostPath(), gum::prm::gspan::EdgeGrowth< GUM_SCALAR >::toString(), and gum::prm::gspan::EdgeData< GUM_SCALAR >::u.

Referenced by discoverPatterns().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discoverPatterns()

template<GUM_Numeric 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 57 of file gspan_tpl.h.

57 {
58 Timer t;
61
62 for (auto root = _tree_.roots().begin(); root != _tree_.roots().end(); ++root) {
63 if (_tree_.strategy().accept_root(&(_tree_.pattern(*root)))) {
64 gspan::Pattern& p = _tree_.pattern(*root);
66
67 for (const auto node: _tree_.iso_graph(p).nodes()) {
68 PRMInstance< GUM_SCALAR >* u = _tree_.iso_map(p, node).atPos(0);
69 PRMInstance< GUM_SCALAR >* v = _tree_.iso_map(p, node).atPos(1);
70 graph.internalGraph().eraseEdge(Edge(graph.id(u), graph.id(v)));
71 }
72 }
73 }
74
76 }
Edge(NodeId aN1, NodeId aN2)
constructs a new edge (aN1,aN2)
void _subgraph_mining_(gspan::InterfaceGraph< GUM_SCALAR > &graph, gspan::Pattern &p)
Discovers new patterns by developing p.
Definition gspan_tpl.h:121
void _sortNodesAndEdges_()
Sort the nodes and edges of graph.
Definition gspan_tpl.h:79
void _sortPatterns_()
Sort the patterns and compute their respective costs.
Definition gspan_tpl.h:241

References gum::Edge::Edge(), _graph_, _sortNodesAndEdges_(), _sortPatterns_(), _subgraph_mining_(), and _tree_.

Here is the call graph for this function:

◆ getMaxDFSDepth()

template<GUM_Numeric GUM_SCALAR>
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 385 of file gspan_tpl.h.

385 {
386 return _depth_stop_;
387 }

References _depth_stop_.

◆ interfaceGraph() [1/2]

template<GUM_Numeric GUM_SCALAR>
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 432 of file gspan_tpl.h.

432 {
433 return *_graph_;
434 }

References _graph_.

◆ interfaceGraph() [2/2]

template<GUM_Numeric GUM_SCALAR>
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 437 of file gspan_tpl.h.

437 {
438 return *_graph_;
439 }

References _graph_.

◆ matches() [1/2]

template<GUM_Numeric GUM_SCALAR>
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 421 of file gspan_tpl.h.

421 {
422 return *(_matched_instances_[const_cast< gspan::Pattern* >(&p)]);
423 }

References _matched_instances_.

Referenced by _sortPatterns_().

Here is the caller graph for this function:

◆ matches() [2/2]

template<GUM_Numeric GUM_SCALAR>
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 427 of file gspan_tpl.h.

427 {
428 return *(_matched_instances_[const_cast< gspan::Pattern* >(&p)]);
429 }

References _matched_instances_.

◆ patterns() [1/2]

template<GUM_Numeric GUM_SCALAR>
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 410 of file gspan_tpl.h.

410 {
411 return _patterns_;
412 }

References _patterns_.

◆ patterns() [2/2]

template<GUM_Numeric GUM_SCALAR>
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 415 of file gspan_tpl.h.

415 {
416 return _patterns_;
417 }

References _patterns_.

◆ setMaxDFSDepth()

template<GUM_Numeric GUM_SCALAR>
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 390 of file gspan_tpl.h.

390 {
392 }

References _depth_stop_.

◆ tree() [1/2]

template<GUM_Numeric GUM_SCALAR>
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 395 of file gspan_tpl.h.

395 {
396 return _tree_;
397 }

References _tree_.

Referenced by _sortPatterns_().

Here is the caller graph for this function:

◆ tree() [2/2]

template<GUM_Numeric GUM_SCALAR>
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 400 of file gspan_tpl.h.

400 {
401 return _tree_;
402 }

References _tree_.

Member Data Documentation

◆ _chosen_

template<GUM_Numeric 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 257 of file gspan.h.

Referenced by _sortPatterns_().

◆ _cost_

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

Mapping between labels and their cost.

Definition at line 250 of file gspan.h.

Referenced by _sortNodesAndEdges_().

◆ _depth_stop_

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

The max depth allowed for the DSF tree.

Definition at line 238 of file gspan.h.

Referenced by GSpan(), _subgraph_mining_(), getMaxDFSDepth(), and setMaxDFSDepth().

◆ _edges_

template<GUM_Numeric 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 247 of file gspan.h.

Referenced by _sortNodesAndEdges_().

◆ _graph_

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

The interface graph used by this class.

Definition at line 232 of file gspan.h.

Referenced by GSpan(), ~GSpan(), _isEdgeEligible_(), _sortNodesAndEdges_(), discoverPatterns(), interfaceGraph(), and interfaceGraph().

◆ _matched_instances_

template<GUM_Numeric 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 254 of file gspan.h.

Referenced by ~GSpan(), _sortPatterns_(), matches(), and matches().

◆ _nodes_

template<GUM_Numeric 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 244 of file gspan.h.

Referenced by _sortNodesAndEdges_().

◆ _patterns_

template<GUM_Numeric 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 241 of file gspan.h.

Referenced by _sortPatterns_(), patterns(), and patterns().

◆ _tree_

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

The DFSTree used to discover new patters.

Definition at line 235 of file gspan.h.

Referenced by GSpan(), _sortNodesAndEdges_(), _subgraph_mining_(), discoverPatterns(), tree(), and tree().


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