aGrUM  0.14.2
interfaceGraph.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_INTERFACE_GRAPH_H
27 #define GUM_INTERFACE_GRAPH_H
28 
29 #include <list>
30 #include <sstream>
31 #include <string>
32 
33 #include <agrum/PRM/PRM.h>
34 #include <agrum/core/hashTable.h>
35 #include <agrum/graphs/undiGraph.h>
36 
37 namespace gum {
38  namespace prm {
39  template < typename GUM_SCALAR >
40  class GSpan;
41 
42  namespace gspan {
43 
48  struct LabelData {
50  LabelData();
52  LabelData(const LabelData& from);
54  ~LabelData();
58  std::string l;
62  bool operator==(const LabelData& from) const;
64  bool operator!=(const LabelData& from) const;
65  };
66 
73  std::ostream& operator<<(std::ostream& out, const LabelData& data);
74 
79  template < typename GUM_SCALAR >
80  class NodeData {
81  public:
93  bool operator==(const NodeData< GUM_SCALAR >& from) const;
95  bool operator!=(const NodeData< GUM_SCALAR >& from) const;
96  };
97 
104  template < typename GUM_SCALAR >
105  std::ostream& operator<<(std::ostream& out,
106  const NodeData< GUM_SCALAR >& data);
107 
112  template < typename GUM_SCALAR >
113  class EdgeData {
114  public:
116  EdgeData();
118  EdgeData(const EdgeData< GUM_SCALAR >& from);
120  ~EdgeData();
132  bool operator==(const EdgeData< GUM_SCALAR >& from) const;
134  bool operator!=(const EdgeData< GUM_SCALAR >& from) const;
135  };
136 
143  template < typename GUM_SCALAR >
144  std::ostream& operator<<(std::ostream& out,
145  const EdgeData< GUM_SCALAR >& data);
146 
163  template < typename GUM_SCALAR >
165  friend class gum::prm::GSpan< GUM_SCALAR >;
166 
167  public:
169  explicit InterfaceGraph(const PRMSystem< GUM_SCALAR >& sys);
170 
172  InterfaceGraph(const InterfaceGraph& source);
173 
175  InterfaceGraph& operator=(const InterfaceGraph& source);
176 
178  ~InterfaceGraph();
179 
181  UndiGraph& graph();
182 
184  const UndiGraph& graph() const;
185 
189 
192  const Bijection< Idx, LabelData* >& labels() const;
193 
195  Size size(const LabelData* l) const;
196 
198  Set< NodeData< GUM_SCALAR >* >& nodes(const LabelData* l);
199 
201  const Set< NodeData< GUM_SCALAR >* >& nodes(const LabelData* l) const;
202 
204  Set< EdgeData< GUM_SCALAR >* >& edges(const LabelData* l);
205 
207  const Set< EdgeData< GUM_SCALAR >* >& edges(const LabelData* l) const;
208 
210  LabelData* label(Idx id);
211 
213  NodeId id(const PRMInstance< GUM_SCALAR >& i) const;
214 
216  NodeId id(const PRMInstance< GUM_SCALAR >* i) const;
217 
221 
225  node(const PRMInstance< GUM_SCALAR >* i) const;
226 
229  NodeData< GUM_SCALAR >& node(NodeId id);
230 
233  const NodeData< GUM_SCALAR >& node(NodeId id) const;
234 
238 
241  const EdgeData< GUM_SCALAR >& edge(NodeId u, NodeId v) const;
242 
243  private:
247 
250 
253 
256 
259 
262 
267 
272 
275 
278 
281  void __label(NodeData< GUM_SCALAR >* node,
283 
286  void __label(EdgeData< GUM_SCALAR >* edge,
288  };
289 
290 
291 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
292 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
293 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
294  extern template class NodeData< double >;
295 # endif
296 # endif
297 #endif
298 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
299 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
300 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
301  extern template class EdgeData< double >;
302 # endif
303 # endif
304 #endif
305 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
306 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
307 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
308  extern template class InterfaceGraph< double >;
309 # endif
310 # endif
311 #endif
312 
313 
314  } /* namespace gspan */
315  } /* namespace prm */
316 } /* namespace gum */
317 
319 
320 #endif /* GUM_INTERFACE_GRAPH_H */
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
Definition: DFSCode.cpp:37
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:60
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.
Headers of PRM.
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.
Base classes for undirected graphs.
This class represent the interface graph of a given gum::prm::PRMSystem<GUM_SCALAR>.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
EdgeProperty< EdgeData< GUM_SCALAR > *> __edges
Data associated with edges in __graph.
The class for generic Hash Tables.
Definition: hashTable.h:676
LabelData * l
The labal data of this edge.
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
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:226
LabelData * l
The label of this node.
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
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:54
Bijection< Idx, LabelData *> * __labels
Bijection between labels and their ids.
Base class for undirected graphs.
Definition: undiGraph.h:106
Inline implementation of gum::InterfaceGraph.
Size Idx
Type for indexes.
Definition: types.h:50
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:45
Class hash tables iterators.
Size NodeId
Type for node ids.
Definition: graphElements.h:97