aGrUM  0.17.2
a C++ library for (probabilistic) graphical models
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: public virtual NodeGraphPart, public EdgeGraphPart {
110  public:
111  // ############################################################################
113  // ############################################################################
115 
117 
121  explicit UndiGraph(Size nodes_size = HashTableConst::default_size,
122  bool nodes_resize_policy = true,
123  Size edges_size = HashTableConst::default_size,
124  bool edges_resize_policy = true);
125 
127 
128  UndiGraph(const UndiGraph& g);
129 
131  virtual ~UndiGraph();
132 
134 
135  // ############################################################################
137  // ############################################################################
139 
141 
142  UndiGraph& operator=(const UndiGraph& g);
143 
145 
146  // not virtual : it is a feature !!! :)
147  bool operator==(const UndiGraph& g) const;
148 
150 
151  // not virtual : it is a feature !!! :)
152  bool operator!=(const UndiGraph& g) const;
153 
155 
156  // ############################################################################
158  // ############################################################################
160 
162 
169  virtual void addEdge(const NodeId first, const NodeId second);
170 
172 
175  virtual void eraseNode(const NodeId id);
176 
178  virtual void clear();
179 
181  virtual const std::string toString() const;
182 
184  virtual const std::string toDot() const;
185 
187  bool hasUndirectedCycle() const;
188 
190  virtual UndiGraph partialUndiGraph(NodeSet nodesSet);
191 
193  };
194 
196  std::ostream& operator<<(std::ostream&, const UndiGraph&);
197 
198 } /* namespace gum */
199 
200 #ifndef GUM_NO_INLINE
202 #endif // GUM_NOINLINE
203 
204 #endif /* GUM_UNDIGRAPH_H */
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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:626
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