aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
edgeGrowth.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by 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, LabelData* an_edge, LabelData* a_l_v, NodeId a_v = 0);
67  /// Copy constructor.
68  EdgeGrowth(const EdgeGrowth& from);
69  /// Destructor.
70  ~EdgeGrowth();
71  /// The id of the node from which we grow an edge.
72  NodeId u;
73  /// The LabelData over the edge of this edge growth.
74  LabelData* edge;
75  /// The LabelData over the node of this edge growth.
76  LabelData* l_v;
77  /// If the growth is backward you must assigned the subscript of v,
78  /// otherwise 0 is assigned (recall that subscripts start from 1)
79  NodeId v;
80  /// Add the pair (u,v) as a match for the current growth.
81  void insert(PRMInstance< GUM_SCALAR >* u, PRMInstance< GUM_SCALAR >* v);
82  /// The mapping between the u and v for each match in the interface
83  /// graph.
84  NodeProperty< std::pair< PRMInstance< GUM_SCALAR >*, PRMInstance< GUM_SCALAR >* > > matches;
85  /// Return a string representation of this
86  std::string toString();
87 
88  private:
89  /// The iso graph for computing the maximum independent set of matches.
90  UndiGraph iso_graph;
91  /// Vector used for computation
92  std::vector< NodeId >* degree_list;
93  /// The max indep set of matches
94  Set< NodeId > max_indep_set;
95  };
96 
97  template < typename GUM_SCALAR >
98  std::ostream& operator<<(std::ostream& out, const EdgeGrowth< GUM_SCALAR >& edge);
99 
100 
101 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
102  extern template class EdgeGrowth< double >;
103 #endif
104 
105 
106  } /* namespace gspan */
107  } /* namespace prm */
108 } /* namespace gum */
109 
110 #include <agrum/PRM/gspan/edgeGrowth_tpl.h>
111 
112 #endif /* GUM_EDGE_GROWTH_H */