aGrUM  0.16.0
gspan.h
Go to the documentation of this file.
1 
30 #ifndef GUM_GSPAN_H
31 #define GUM_GSPAN_H
32 
33 #include <algorithm>
34 #include <list>
35 #include <ostream>
36 #include <string>
37 #include <vector>
38 
39 #include <agrum/core/timer.h>
40 
42 
43 #include <agrum/PRM/PRM.h>
46 
47 namespace gum {
48  namespace prm {
49 
70  template < typename GUM_SCALAR >
71  class GSpan {
72  public:
73  // ========================================================================
75  // ========================================================================
77 
86  GSpan(const PRM< GUM_SCALAR >& prm,
87  const PRMSystem< GUM_SCALAR >& sys,
88  gspan::SearchStrategy< GUM_SCALAR >* strategy = 0);
89 
91  ~GSpan();
92 
94  // ========================================================================
96  // ========================================================================
98 
104  Size getMaxDFSDepth() const;
105 
112  void setMaxDFSDepth(Size depth);
113 
118  gspan::DFSTree< GUM_SCALAR >& tree();
119 
124  const gspan::DFSTree< GUM_SCALAR >& tree() const;
125 
130  gspan::InterfaceGraph< GUM_SCALAR >& interfaceGraph();
131 
136  const gspan::InterfaceGraph< GUM_SCALAR >& interfaceGraph() const;
137 
139  // ========================================================================
141  // ========================================================================
143 
151  void discoverPatterns();
152 
159  std::vector< gspan::Pattern* >& patterns();
160 
167  const std::vector< gspan::Pattern* >& patterns() const;
168 
171 
178  MatchedInstances& matches(const gspan::Pattern& p);
179 
186  const MatchedInstances& matches(const gspan::Pattern& p) const;
187 
188  // /**
189  // * Returns the cumulative sum of all the cliques size created after
190  // lifting
191  // * the patterns.
192  // * @returns the cumulative sum of all the cliques size created after
193  // lifting
194  // * the patterns.
195  // */
196  // double patterns_cost() const;
197 
198  // /**
199  // * Returns the cumulative sum of all the cliques size created after
200  // lifting
201  // * the inner attributes.
202  // * @returns the cumulative sum of all the cliques size created after
203  // lifting
204  // * the inner attributes.
205  // */
206  // double sve_cost() const;
207 
209  private:
210  // ========================================================================
212  // ========================================================================
214 
217 
220 
223 
225  std::vector< gspan::Pattern* > __patterns;
226 
228  std::vector< gspan::LabelData* > __nodes;
229 
231  std::vector< gspan::LabelData* > __edges;
232 
235 
239 
242 
244  // ========================================================================
246  // ========================================================================
248 
250  void __sortNodesAndEdges();
251 
256  gspan::Pattern& p);
257 
264  Size __cost_func(Size interface_size, Size frequency);
265 
267  void __sortPatterns();
268 
273 
275 
276  // ========================================================================
278  // ========================================================================
280 
286  struct LabelSort {
291  LabelSort(GSpan* my_gspan);
292 
297  LabelSort(const LabelSort& source);
298 
302  ~LabelSort();
303 
311 
314  };
315 
321  struct PatternSort {
326  PatternSort(GSpan* my_gspan);
327 
332  PatternSort(const PatternSort& source);
333 
337  ~PatternSort();
338 
346 
349  };
350 
352  };
353 
354 
355 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
356  extern template class GSpan< double >;
357 #endif
358 
359 
360  } /* namespace prm */
361 } /* namespace gum */
362 
364 
365 #endif /* GUM_GSPAN_H */
GSpan * gspan
A pointer over an instance of the GSpan class using this class.
Definition: gspan.h:313
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
Set< Sequence< PRMInstance< GUM_SCALAR > *> *> MatchedInstances
Code alias.
Definition: gspan.h:170
Inner class to handle data about labels in this interface graph.
HashTable< gspan::LabelData *, Idx > __cost
Mapping between labels and their cost.
Definition: gspan.h:234
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
LabelSort(GSpan *my_gspan)
Default constructor.
Definition: gspan_tpl.h:445
Size __depth_stop
The max depth allowed for the DSF tree.
Definition: gspan.h:222
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Inner class to handle data about edges in __graph.
void __subgraph_mining(gspan::InterfaceGraph< GUM_SCALAR > &graph, gspan::Pattern &p)
Discovers new patterns by developing p.
Definition: gspan_tpl.h:103
This class represent the interface graph of a given gum::prm::PRMSystem<GUM_SCALAR>.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void __sortPatterns()
Sort the patterns and compute their respective costs.
Definition: gspan_tpl.h:225
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
Definition: hashTable.h:679
Set< PRMInstance< GUM_SCALAR > *> __chosen
Contains all instance which belongs to a discovered and used pattern.
Definition: gspan.h:241
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
gspan::DFSTree< GUM_SCALAR > __tree
The DFSTree used to discover new patters.
Definition: gspan.h:219
A DFSTree is used by gspan to sort lexicographically patterns discovered in an interface graph...
Definition: DFSTree.h:71
~GSpan()
Destructor.
Definition: gspan_tpl.h:364
~LabelSort()
Destructor.
Definition: gspan_tpl.h:457
std::vector< gspan::Pattern *> __patterns
The vector of discovered patters, in decreasing order of interest.
Definition: gspan.h:225
gspan::InterfaceGraph< GUM_SCALAR > * __graph
The interface graph used by this class.
Definition: gspan.h:216
Private class used to sort LabelData using STL sort algorithms.
Definition: gspan.h:286
GSpan * gspan
A pointer over an instance of the GSpan class using this class.
Definition: gspan.h:348
gspan::DFSTree< GUM_SCALAR > & tree()
Returns the DFSTree used to discover new patters.
Definition: gspan_tpl.h:384
gspan::InterfaceGraph< GUM_SCALAR > & interfaceGraph()
Returns the InterfaceGraph used by this.
Definition: gspan_tpl.h:424
void discoverPatterns()
This will methods will discover repeated patterns in the PRMSystem<GUM_SCALAR> assigned to this class...
Definition: gspan_tpl.h:36
This class discovers pattern in a PRM<GUM_SCALAR>&#39;s PRMSystem<GUM_SCALAR> to speed up structured infe...
Definition: DFSTree.h:57
std::vector< gspan::Pattern *> & patterns()
Returns the Pattern mined by this class in a decreasing order of interest.
Definition: gspan_tpl.h:400
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void setMaxDFSDepth(Size depth)
Defines the maximal depth of the DFSTree used by this class to discover new patterns.
Definition: gspan_tpl.h:379
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __sortNodesAndEdges()
Sort the nodes and edges of __graph.
Definition: gspan_tpl.h:59
GSpan(const PRM< GUM_SCALAR > &prm, const PRMSystem< GUM_SCALAR > &sys, gspan::SearchStrategy< GUM_SCALAR > *strategy=0)
Default constructor.
Definition: gspan_tpl.h:355
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
Private class used to sort Pattern using STL sort algorithms.
Definition: gspan.h:321
Size getMaxDFSDepth() const
Returns the maximal depth of the DFSTree used to discover new patterns.
Definition: gspan_tpl.h:374
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
This contains all the information we want for a node in a DFSTree.
Definition: pattern.h:73
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
bool operator()(gspan::LabelData *i, gspan::LabelData *j)
Returns true if i&#39;s cost is lesser than j&#39;s.
Definition: gspan_tpl.h:462
HashTable< gspan::Pattern *, MatchedInstances *> __matched_instances
Mapping between a pattern and the multiset of instances matched to it.
Definition: gspan.h:238