aGrUM  0.16.0
edgeGraphPart.h
Go to the documentation of this file.
1 
23 #ifndef GUM_EDGE_GRAPH_PART_H
24 #define GUM_EDGE_GRAPH_PART_H
25 
26 
27 #include <agrum/agrum.h>
28 #include <algorithm>
29 #include <utility>
30 
32 
34 
35 namespace gum {
36 
75  class EdgeGraphPart {
76  public:
78 
79  Signaler2< NodeId, NodeId > onEdgeAdded;
80  Signaler2< NodeId, NodeId > onEdgeDeleted;
81 
82  // ############################################################################
84  // ############################################################################
86 
88 
90  explicit EdgeGraphPart(Size edges_size = HashTableConst::default_size,
91  bool edges_resize_policy = true);
92 
94 
95  EdgeGraphPart(const EdgeGraphPart& s);
96 
98  virtual ~EdgeGraphPart();
99 
101 
102  // ############################################################################
104  // ############################################################################
106 
108 
110 
112 
113  bool operator==(const EdgeGraphPart& p) const;
114 
116 
117  bool operator!=(const EdgeGraphPart& p) const;
118 
120 
121  // ############################################################################
123  // ############################################################################
125 
127 
131  virtual void addEdge(const NodeId n1, const NodeId n2);
132 
134 
138  virtual void eraseEdge(const Edge& edge);
139 
141 
143  bool existsEdge(const Edge& edge) const;
144 
146 
150  bool existsEdge(const NodeId n1, const NodeId n2) const;
151 
153  bool emptyEdges() const;
154 
156  virtual void clearEdges();
157 
159  Size sizeEdges() const;
160 
162  const EdgeSet& edges() const;
163 
165 
168  const NodeSet& neighbours(const NodeId id) const;
169 
171 
176  void eraseNeighbours(const NodeId id);
177 
180 
181  void unvirtualizedEraseNeighbours(const NodeId id);
182 
184  const std::string toString() const;
185 
194  template < typename VAL >
195  EdgeProperty< VAL > edgesProperty(VAL (*f)(const Edge&), Size size = 0) const;
196 
205  template < typename VAL >
206  EdgeProperty< VAL > edgesProperty(const VAL& a, Size size = 0) const;
207 
211  template < typename VAL >
212  List< VAL > listMapEdges(VAL (*f)(const Edge&)) const;
213 
215 
219  const std::vector< NodeId > undirectedPath(const NodeId node1,
220  const NodeId node2) const;
221 
223 
224  private:
227 
230 
234  void __checkNeighbours(const NodeId id) const;
235  };
236 
238  std::ostream& operator<<(std::ostream&, const EdgeGraphPart&);
239 
240 } /* namespace gum */
241 
242 #ifndef GUM_NO_INLINE
244 #endif // GUM_NOINLINE
245 
247 
248 #endif // GUM_EDGEGRAPHPART_H
const std::vector< NodeId > undirectedPath(const NodeId node1, const NodeId node2) const
returns a possible path from node1 to node2 in the edge set
EdgeGraphPart(Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
EdgeSetIterator EdgeIterator
Definition: edgeGraphPart.h:77
bool operator==(const EdgeGraphPart &p) const
tests whether two EdgeGraphParts contain the same edges
EdgeGraphPart & operator=(const EdgeGraphPart &s)
copy operator
bool emptyEdges() const
indicates wether the EdgeGraphPart contains any edge
virtual void addEdge(const NodeId n1, const NodeId n2)
insert a new edge into the EdgeGraphPart
NodeProperty< NodeSet *> __neighbours
for each node, the set of its adjacent edges
static constexpr Size default_size
The default number of slots in hashtables.
Definition: hashTable.h:80
Classes for undirected edge sets.
Definition: edgeGraphPart.h:75
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
Definition: hashTable.h:679
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const NodeSet & neighbours(const NodeId id) const
returns the set of edges adjacent to a given node
EdgeProperty< VAL > edgesProperty(VAL(*f)(const Edge &), Size size=0) const
a method to create a hashMap of VAL from a set of edges (using for every edge, say x...
void __checkNeighbours(const NodeId id) const
when the EdgeGraphPart contains no edge adjacent to a given node, this function adds an empty set ent...
virtual void clearEdges()
removes all the edges from the EdgeGraphPart
const EdgeSet & edges() const
returns the set of edges stored within the EdgeGraphPart
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
List< VAL > listMapEdges(VAL(*f)(const Edge &)) const
a method to create a list of VAL from a set of edges (using for every edge, say x, the VAL f(x))
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
virtual ~EdgeGraphPart()
destructor
Signaler2< NodeId, NodeId > onEdgeDeleted
Definition: edgeGraphPart.h:80
Unsafe iterators for the Set class.
Definition: set.h:1025
const std::string toString() const
to friendly display the content of the EdgeGraphPart
bool operator!=(const EdgeGraphPart &p) const
tests whether two EdgeGraphParts contain different edges
The base class for all undirected edges.
Size sizeEdges() const
indicates the number of edges stored within the EdgeGraphPart
void unvirtualizedEraseNeighbours(const NodeId id)
same function as eraseNeighbours but without any virtual call to an erase
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
Signaler2< NodeId, NodeId > onEdgeAdded
Definition: edgeGraphPart.h:79
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void eraseNeighbours(const NodeId id)
erase all the edges adjacent to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
EdgeSet __edges
the set of all the edges contained within the EdgeGraphPart