aGrUM  0.16.0
undiGraph.h
Go to the documentation of this file.
1 
28 #ifndef GUM_UNDIGRAPH_H
29 #define GUM_UNDIGRAPH_H
30 
31 #include <iostream>
32 #include <utility>
33 
34 #include <agrum/agrum.h>
35 
38 
39 namespace gum {
40 
41  /* ===========================================================================
42  */
43  /* === BASE CLASS FOR MANIPULATING ALL UNDIRECTED GRAPHS ===
44  */
45  /* ===========================================================================
46  */
106  /* ===========================================================================
107  */
108 
109  class UndiGraph
110  : public virtual NodeGraphPart
111  , public EdgeGraphPart {
112  public:
113  // ############################################################################
115  // ############################################################################
117 
119 
123  explicit UndiGraph(Size nodes_size = HashTableConst::default_size,
124  bool nodes_resize_policy = true,
125  Size edges_size = HashTableConst::default_size,
126  bool edges_resize_policy = true);
127 
129 
130  UndiGraph(const UndiGraph& g);
131 
133  virtual ~UndiGraph();
134 
136 
137  // ############################################################################
139  // ############################################################################
141 
143 
144  UndiGraph& operator=(const UndiGraph& g);
145 
147 
148  // not virtual : it is a feature !!! :)
149  bool operator==(const UndiGraph& g) const;
150 
152 
153  // not virtual : it is a feature !!! :)
154  bool operator!=(const UndiGraph& g) const;
155 
157 
158  // ############################################################################
160  // ############################################################################
162 
164 
171  virtual void addEdge(const NodeId first, const NodeId second);
172 
174 
177  virtual void eraseNode(const NodeId id);
178 
180  virtual void clear();
181 
183  virtual const std::string toString() const;
184 
186  virtual const std::string toDot() const;
187 
189  bool hasUndirectedCycle() const;
190 
192  virtual UndiGraph partialUndiGraph(NodeSet nodesSet);
193 
195  };
196 
198  std::ostream& operator<<(std::ostream&, const UndiGraph&);
199 
200 } /* namespace gum */
201 
202 #ifndef GUM_NO_INLINE
204 #endif // GUM_NOINLINE
205 
206 #endif /* GUM_UNDIGRAPH_H */
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.
virtual void clear()
removes all the nodes and edges from the graph
Definition: undiGraph_inl.h:43
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
Definition: undiGraph_inl.h:35
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual void eraseNode(const NodeId id)
remove a node and its adjacent edges from the graph
Definition: undiGraph_inl.h:58
virtual ~UndiGraph()
destructor
Definition: undiGraph.cpp:53
bool operator!=(const UndiGraph &g) const
tests whether two UndiGraphs are different
Definition: undiGraph_inl.h:70
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 operator==(const UndiGraph &g) const
tests whether two UndiGraphs are identical (same nodes, same edges)
Definition: undiGraph_inl.h:66
Class for node sets in graph.
UndiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
Definition: undiGraph.cpp:40
Base class for undirected graphs.
Definition: undiGraph.h:109
bool hasUndirectedCycle() const
checks whether the graph contains cycles
Definition: undiGraph.cpp:55
UndiGraph & operator=(const UndiGraph &g)
copy operator
Definition: undiGraph_inl.h:48
virtual const std::string toString() const
to friendly display the content of the graph
Definition: undiGraph.cpp:102
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
virtual const std::string toDot() const
to friendly display graph in DOT format
Definition: undiGraph.cpp:109
virtual UndiGraph partialUndiGraph(NodeSet nodesSet)
returns the partial graph formed by the nodes given in parameter
Definition: undiGraph.cpp:139