aGrUM  0.16.0
interfaceGraph.h
Go to the documentation of this file.
1 
29 #ifndef GUM_INTERFACE_GRAPH_H
30 #define GUM_INTERFACE_GRAPH_H
31 
32 #include <list>
33 #include <sstream>
34 #include <string>
35 
36 #include <agrum/PRM/PRM.h>
37 #include <agrum/core/hashTable.h>
38 #include <agrum/graphs/undiGraph.h>
39 
40 namespace gum {
41  namespace prm {
42  template < typename GUM_SCALAR >
43  class GSpan;
44 
45  namespace gspan {
46 
51  struct LabelData {
53  LabelData();
55  LabelData(const LabelData& from);
57  ~LabelData();
61  std::string l;
65  bool operator==(const LabelData& from) const;
67  bool operator!=(const LabelData& from) const;
68  };
69 
76  std::ostream& operator<<(std::ostream& out, const LabelData& data);
77 
82  template < typename GUM_SCALAR >
83  class NodeData {
84  public:
96  bool operator==(const NodeData< GUM_SCALAR >& from) const;
98  bool operator!=(const NodeData< GUM_SCALAR >& from) const;
99  };
100 
107  template < typename GUM_SCALAR >
108  std::ostream& operator<<(std::ostream& out,
109  const NodeData< GUM_SCALAR >& data);
110 
115  template < typename GUM_SCALAR >
116  class EdgeData {
117  public:
119  EdgeData();
121  EdgeData(const EdgeData< GUM_SCALAR >& from);
123  ~EdgeData();
135  bool operator==(const EdgeData< GUM_SCALAR >& from) const;
137  bool operator!=(const EdgeData< GUM_SCALAR >& from) const;
138  };
139 
146  template < typename GUM_SCALAR >
147  std::ostream& operator<<(std::ostream& out,
148  const EdgeData< GUM_SCALAR >& data);
149 
166  template < typename GUM_SCALAR >
168  friend class gum::prm::GSpan< GUM_SCALAR >;
169 
170  public:
172  explicit InterfaceGraph(const PRMSystem< GUM_SCALAR >& sys);
173 
175  InterfaceGraph(const InterfaceGraph& source);
176 
178  InterfaceGraph& operator=(const InterfaceGraph& source);
179 
181  ~InterfaceGraph();
182 
184  UndiGraph& graph();
185 
187  const UndiGraph& graph() const;
188 
192 
195  const Bijection< Idx, LabelData* >& labels() const;
196 
198  Size size(const LabelData* l) const;
199 
201  Set< NodeData< GUM_SCALAR >* >& nodes(const LabelData* l);
202 
204  const Set< NodeData< GUM_SCALAR >* >& nodes(const LabelData* l) const;
205 
207  Set< EdgeData< GUM_SCALAR >* >& edges(const LabelData* l);
208 
210  const Set< EdgeData< GUM_SCALAR >* >& edges(const LabelData* l) const;
211 
213  LabelData* label(Idx id);
214 
216  NodeId id(const PRMInstance< GUM_SCALAR >& i) const;
217 
219  NodeId id(const PRMInstance< GUM_SCALAR >* i) const;
220 
224 
228  node(const PRMInstance< GUM_SCALAR >* i) const;
229 
232  NodeData< GUM_SCALAR >& node(NodeId id);
233 
236  const NodeData< GUM_SCALAR >& node(NodeId id) const;
237 
241 
244  const EdgeData< GUM_SCALAR >& edge(NodeId u, NodeId v) const;
245 
246  private:
250 
253 
256 
259 
262 
265 
270 
275 
278 
281 
284  void __label(NodeData< GUM_SCALAR >* node,
286 
289  void __label(EdgeData< GUM_SCALAR >* edge,
291  };
292 
293 
294 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
295 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
296 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
297  extern template class NodeData< double >;
298 # endif
299 # endif
300 #endif
301 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
302 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
303 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
304  extern template class EdgeData< double >;
305 # endif
306 # endif
307 #endif
308 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
309 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
310 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
311  extern template class InterfaceGraph< double >;
312 # endif
313 # endif
314 #endif
315 
316 
317  } /* namespace gspan */
318  } /* namespace prm */
319 } /* namespace gum */
320 
322 
323 #endif /* GUM_INTERFACE_GRAPH_H */
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
Definition: DFSCode.cpp:40
Inner class to handle data about labels in this interface graph.
PRMInstance< GUM_SCALAR > * u
One of the two instance represented by this edge.
PRMInstance< GUM_SCALAR > * n
The instance represented by this node.
An PRMInstance is a Bayesian Network fragment defined by a Class and used in a PRMSystem.
Definition: PRMInstance.h:63
std::string l
The string version of this label.
bool operator==(const LabelData &from) const
Equality operator.
NodeProperty< NodeData< GUM_SCALAR > *> __nodes
Data associated with a node in __graph.
HashTable< LabelData *, Set< NodeData< GUM_SCALAR > *> *> __nodeMap
Mapping between a LabelData and the set of NodeData<GUM_SCALAR> with that label.
UndiGraph __graph
The interface graph.
LabelData * l_u
The label data of u.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Inner class to handle data about edges in __graph.
Idx __counter
A counter used of assigning ids to labels.
PRMInstance< GUM_SCALAR > * v
The other instance represented by thus edge.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Definition: agrum.h:25
EdgeProperty< EdgeData< GUM_SCALAR > *> __edges
Data associated with edges in __graph.
The class for generic Hash Tables.
Definition: hashTable.h:679
LabelData * l
The labal data of this edge.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:165
const PRMSystem< GUM_SCALAR > * __sys
The gum::prm::PRMSystem<GUM_SCALAR> represented by this interface graph.
HashTable< LabelData *, Set< EdgeData< GUM_SCALAR > *> *> __edgeMap
Mapping between a LabelData and the set of EdgeData<GUM_SCALAR> with that label.
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
LabelData * l
The label of this node.
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
bool operator!=(const LabelData &from) const
Difference operator.
Inner class to handle data about nodes in __graph.
Idx id
An unique identifier for this label.
bool __erase_flag
For shallow copies.
LabelData * l_v
The label data of v.
HashTable< PRMInstance< GUM_SCALAR > *, NodeId > __idMap
Mapping between PRMInstance<GUM_SCALAR> dans their id in __graph.
This class discovers pattern in a PRM<GUM_SCALAR>&#39;s PRMSystem<GUM_SCALAR> to speed up structured infe...
Definition: DFSTree.h:57
Bijection< Idx, LabelData *> * __labels
Bijection between labels and their ids.
Base class for undirected graphs.
Definition: undiGraph.h:109
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size Idx
Type for indexes.
Definition: types.h:53
Size tree_width
The size in terms of tree width of the given label.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size NodeId
Type for node ids.
Definition: graphElements.h:98