aGrUM  0.14.2
edgeGraphPart.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  ***************************************************************************/
20 #ifndef GUM_EDGE_GRAPH_PART_H
21 #define GUM_EDGE_GRAPH_PART_H
22 
23 
24 #include <agrum/agrum.h>
25 #include <algorithm>
26 #include <utility>
27 
29 
31 
32 namespace gum {
33 
72  class EdgeGraphPart {
73  public:
75 
76  Signaler2< NodeId, NodeId > onEdgeAdded;
77  Signaler2< NodeId, NodeId > onEdgeDeleted;
78 
79  // ############################################################################
81  // ############################################################################
83 
85 
87  explicit EdgeGraphPart(Size edges_size = HashTableConst::default_size,
88  bool edges_resize_policy = true);
89 
91 
92  EdgeGraphPart(const EdgeGraphPart& s);
93 
95  virtual ~EdgeGraphPart();
96 
98 
99  // ############################################################################
101  // ############################################################################
103 
105 
107 
109 
110  bool operator==(const EdgeGraphPart& p) const;
111 
113 
114  bool operator!=(const EdgeGraphPart& p) const;
115 
117 
118  // ############################################################################
120  // ############################################################################
122 
124 
128  virtual void addEdge(const NodeId n1, const NodeId n2);
129 
131 
135  virtual void eraseEdge(const Edge& edge);
136 
138 
140  bool existsEdge(const Edge& edge) const;
141 
143 
147  bool existsEdge(const NodeId n1, const NodeId n2) const;
148 
150  bool emptyEdges() const;
151 
153  virtual void clearEdges();
154 
156  Size sizeEdges() const;
157 
159  const EdgeSet& edges() const;
160 
162 
165  const NodeSet& neighbours(const NodeId id) const;
166 
168 
173  void eraseNeighbours(const NodeId id);
174 
177 
178  void unvirtualizedEraseNeighbours(const NodeId id);
179 
181  const std::string toString() const;
182 
191  template < typename VAL >
192  EdgeProperty< VAL > edgesProperty(VAL (*f)(const Edge&), Size size = 0) const;
193 
202  template < typename VAL >
203  EdgeProperty< VAL > edgesProperty(const VAL& a, Size size = 0) const;
204 
208  template < typename VAL >
209  List< VAL > listMapEdges(VAL (*f)(const Edge&)) const;
210 
212 
216  const std::vector< NodeId > undirectedPath(const NodeId node1,
217  const NodeId node2) const;
218 
220 
221  private:
224 
227 
231  void __checkNeighbours(const NodeId id) const;
232  };
233 
235  std::ostream& operator<<(std::ostream&, const EdgeGraphPart&);
236 
237 } /* namespace gum */
238 
239 #ifndef GUM_NO_INLINE
241 #endif // GUM_NOINLINE
242 
244 
245 #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:74
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:77
Classes for undirected edge sets.
Definition: edgeGraphPart.h:72
Generic doubly linked lists.
Definition: list.h:369
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Inline implementation of classes for undirected edge sets.
The class for generic Hash Tables.
Definition: hashTable.h:676
Classes of signaler.
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:583
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:77
Unsafe iterators for the Set class.
Definition: set.h:1022
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:45
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
Signaler2< NodeId, NodeId > onEdgeAdded
Definition: edgeGraphPart.h:76
Implementation of the EdgeGraphPart.
void eraseNeighbours(const NodeId id)
erase all the edges adjacent to a given node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
some utils for topology : NodeId, Edge, Arc and consorts ...
EdgeSet __edges
the set of all the edges contained within the EdgeGraphPart