aGrUM  0.16.0
arcGraphPart.h
Go to the documentation of this file.
1 
23 #ifndef GUM_ARC_GRAPH_PART_H
24 #define GUM_ARC_GRAPH_PART_H
25 
26 #include <algorithm>
27 #include <utility>
28 
29 #include <agrum/agrum.h>
30 
33 
34 namespace gum {
35 
79  class ArcGraphPart {
80  public:
82 
83  Signaler2< NodeId, NodeId > onArcAdded; // onArcAdded(tail,head)
84  Signaler2< NodeId, NodeId > onArcDeleted; // onArcDeleted(tail,head)
85 
86  // ############################################################################
88  // ############################################################################
90 
92 
94  explicit ArcGraphPart(Size arcs_size = HashTableConst::default_size,
95  bool arcs_resize_policy = true);
96 
98 
99  ArcGraphPart(const ArcGraphPart& s);
100 
102  virtual ~ArcGraphPart();
103 
105 
106  // ############################################################################
108  // ############################################################################
110 
112 
114 
116 
117  bool operator==(const ArcGraphPart& p) const;
118 
120 
121  bool operator!=(const ArcGraphPart& p) const;
122 
124 
125  // ############################################################################
127  // ############################################################################
129 
131 
135  virtual void addArc(const NodeId tail, const NodeId head);
136 
138 
142  virtual void eraseArc(const Arc& arc);
143 
145 
147  bool existsArc(const Arc& arc) const;
148 
150 
154  bool existsArc(const NodeId tail, const NodeId head) const;
155 
157  bool emptyArcs() const;
158 
160  void clearArcs();
161 
163  Size sizeArcs() const;
164 
166  const ArcSet& arcs() const;
167 
169 
172  const NodeSet& parents(const NodeId id) const;
173 
175 
178  const NodeSet& children(const NodeId id) const;
179 
181 
188  void eraseParents(const NodeId id);
189 
191 
192  void unvirtualizedEraseParents(const NodeId id);
193 
195 
202  void eraseChildren(const NodeId id);
203 
205 
206  void unvirtualizedEraseChildren(const NodeId id);
207 
209  const std::string toString() const;
210 
218  template < typename VAL >
219  ArcProperty< VAL > arcsProperty(VAL (*f)(const Arc&), Size size = 0) const;
220 
228  template < typename VAL >
229  ArcProperty< VAL > arcsProperty(const VAL& a, Size size = 0) const;
230 
234  template < typename VAL >
235  List< VAL > listMapArcs(VAL (*f)(const Arc&)) const;
236 
238 
242  const std::vector< NodeId > directedPath(const NodeId node1,
243  const NodeId node2) const;
244 
246 
250  const std::vector< NodeId > directedUnorientedPath(const NodeId node1,
251  const NodeId node2) const;
252 
254 
255  protected:
257 
259  void _eraseSetOfArcs(const ArcSet& set);
260 
262 
265  void _unvirtualizedEraseSetOfArcs(const ArcSet& set);
266 
267  private:
270 
273 
276 
280  void __checkParents(const NodeId id) const;
281 
285  void __checkChildren(const NodeId id) const;
286  };
287 
289 
291  std::ostream& operator<<(std::ostream& s, const ArcGraphPart& a);
292 
293 } /* namespace gum */
294 
295 #ifndef GUM_NO_INLINE
297 #endif // GUM_NOINLINE
298 
300 
301 #endif // GUM_ARC_GRAPH_PART_H
const std::vector< NodeId > directedUnorientedPath(const NodeId node1, const NodeId node2) const
returns an unoriented (directed) path from node1 to node2 in the arc set
void __checkParents(const NodeId id) const
when the ArcGraphPart contains no arc ingoing into a given node, this function adds an empty set entr...
const std::string toString() const
to friendly display the content of the ArcGraphPart
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the ArcGraphPart
ArcGraphPart & operator=(const ArcGraphPart &s)
copy operator
void clearArcs()
removes all the arcs from the ArcGraphPart
Classes for directed edge sets.
Definition: arcGraphPart.h:79
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
ArcProperty< VAL > arcsProperty(VAL(*f)(const Arc &), Size size=0) const
a method to create a hashMap of VAL from a set of arcs (using for every arc, say x, the VAL f(x))
static constexpr Size default_size
The default number of slots in hashtables.
Definition: hashTable.h:80
Generic doubly linked lists.
Definition: list.h:372
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:679
void __checkChildren(const NodeId id) const
when the ArcGraphPart contains no arc outgoing from a given node, this function adds an empty set ent...
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.
void _eraseSetOfArcs(const ArcSet &set)
a (virtualized) function to remove a given set of arcs
std::ostream & operator<<(std::ostream &output, const BayesNet< GUM_SCALAR > &bn)
Prints map&#39;s DAG in output using the Graphviz-dot format.
Definition: BayesNet_tpl.h:605
bool emptyArcs() const
indicates wether the ArcGraphPart contains any arc
bool operator!=(const ArcGraphPart &p) const
tests whether two ArcGraphParts contain different arcs
Size sizeArcs() const
indicates the number of arcs stored within the ArcGraphPart
The base class for all directed edgesThis class is used as a basis for manipulating all directed edge...
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
bool operator==(const ArcGraphPart &p) const
tests whether two ArcGraphParts contain the same arcs
void _unvirtualizedEraseSetOfArcs(const ArcSet &set)
similar to _eraseSetOfArcs except that it is unvirtualized
const std::vector< NodeId > directedPath(const NodeId node1, const NodeId node2) const
returns a directed path from node1 to node2 belonging to the set of arcs
void eraseChildren(const NodeId id)
removes all the children of a given node
NodeProperty< NodeSet *> __parents
for each arc, the sets of its parents
Definition: arcGraphPart.h:272
ArcSetIterator ArcIterator
Definition: arcGraphPart.h:81
Unsafe iterators for the Set class.
Definition: set.h:1025
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
Signaler2< NodeId, NodeId > onArcAdded
Definition: arcGraphPart.h:83
virtual ~ArcGraphPart()
destructor
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
NodeProperty< NodeSet *> __children
for each arc, the set of its children
Definition: arcGraphPart.h:275
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void unvirtualizedEraseChildren(const NodeId id)
same function as eraseChildren but without any virtual call to an erase
void unvirtualizedEraseParents(const NodeId id)
same function as eraseParents but without any virtual call to an erase
Signaler2< NodeId, NodeId > onArcDeleted
Definition: arcGraphPart.h:84
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
List< VAL > listMapArcs(VAL(*f)(const Arc &)) const
a method to create a list of VAL from a set of arcs (using for every arc, say x, the VAL f(x)) ...
Set< Arc > __arcs
the set of all the arcs contained within the ArcGraphPart
Definition: arcGraphPart.h:269
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
ArcGraphPart(Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void eraseParents(const NodeId id)
erase all the parents of a given node
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.