aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
edgeGrowth.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Headers of the DFSTree class.
25  *
26  * @author Lionel TORTI and Pierre-Henri WUILLEMIN(@LIP6)
27  */
28 
29 #ifndef GUM_EDGE_GROWTH_H
30 #define GUM_EDGE_GROWTH_H
31 
32 #include <list>
33 #include <ostream>
34 #include <utility>
35 #include <vector>
36 
37 #include <agrum/tools/core/math/math_utils.h>
38 #include <agrum/tools/core/bijection.h>
39 #include <agrum/tools/core/sequence.h>
40 #include <agrum/tools/core/set.h>
41 
42 #include <agrum/tools/graphs/diGraph.h>
43 
44 #include <agrum/tools/graphs/algorithms/triangulations/partialOrderedTriangulation.h>
45 
46 #include <agrum/PRM/gspan/interfaceGraph.h>
47 #include <agrum/PRM/gspan/pattern.h>
48 
49 namespace gum {
50  namespace prm {
51  namespace gspan {
52  template < typename GUM_SCALAR >
53  class DFSTree;
54 
55  /**
56  * @class EdgeGrowth
57  * @headerfile DFSTree.h <agrum/PRM/DFSTree.h>
58  * This class is used to define an edge growth of a pattern
59  * in this DFSTree.
60  */
61  template < typename GUM_SCALAR >
62  class EdgeGrowth {
63  public:
64  friend class DFSTree< GUM_SCALAR >;
65  /// Constructor.
66  EdgeGrowth(NodeId a_u,
67  LabelData* an_edge,
68  LabelData* a_l_v,
69  NodeId a_v = 0);
70  /// Copy constructor.
71  EdgeGrowth(const EdgeGrowth& from);
72  /// Destructor.
73  ~EdgeGrowth();
74  /// The id of the node from which we grow an edge.
75  NodeId u;
76  /// The LabelData over the edge of this edge growth.
77  LabelData* edge;
78  /// The LabelData over the node of this edge growth.
79  LabelData* l_v;
80  /// If the growth is backward you must assigned the subscript of v,
81  /// otherwise 0 is assigned (recall that subscripts start from 1)
82  NodeId v;
83  /// Add the pair (u,v) as a match for the current growth.
84  void insert(PRMInstance< GUM_SCALAR >* u, PRMInstance< GUM_SCALAR >* v);
85  /// The mapping between the u and v for each match in the interface
86  /// graph.
87  NodeProperty<
88  std::pair< PRMInstance< GUM_SCALAR >*, PRMInstance< GUM_SCALAR >* > >
89  matches;
90  /// Return a string representation of this
91  std::string toString();
92 
93  private:
94  /// The iso graph for computing the maximum independent set of matches.
95  UndiGraph iso_graph;
96  /// Vector used for computation
97  std::vector< NodeId >* degree_list;
98  /// The max indep set of matches
99  Set< NodeId > max_indep_set;
100  };
101 
102  template < typename GUM_SCALAR >
103  std::ostream& operator<<(std::ostream& out,
104  const EdgeGrowth< GUM_SCALAR >& edge);
105 
106 
107 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
108  extern template class EdgeGrowth< double >;
109 #endif
110 
111 
112  } /* namespace gspan */
113  } /* namespace prm */
114 } /* namespace gum */
115 
116 #include <agrum/PRM/gspan/edgeGrowth_tpl.h>
117 
118 #endif /* GUM_EDGE_GROWTH_H */