aGrUM  0.14.2
mixedGraph.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  ***************************************************************************/
25 #ifndef GUM_MIXED_GRAPH_H
26 #define GUM_MIXED_GRAPH_H
27 
28 #include <iostream>
29 #include <utility>
30 
31 #include <agrum/agrum.h>
32 
33 #include <agrum/graphs/diGraph.h>
34 #include <agrum/graphs/undiGraph.h>
35 
36 namespace gum {
37 
38  /* ===========================================================================
39  */
40  /* === BASE CLASS FOR MANIPULATING GRAPHS WITH BOTH EDGES AND ARCS ===
41  */
42  /* ===========================================================================
43  */
121  /* ===========================================================================
122  */
123 
125  : public virtual UndiGraph
126  , public virtual DiGraph {
127  public:
128  // ############################################################################
130  // ############################################################################
132 
134 
140  explicit MixedGraph(Size nodes_size = HashTableConst::default_size,
141  bool nodes_resize_policy = true,
143  bool arcs_resize_policy = true,
144  Size edges_size = HashTableConst::default_size,
145  bool edges_resize_policy = true);
146 
148 
149  MixedGraph(const MixedGraph& g);
150 
152  virtual ~MixedGraph();
153 
155 
156  // ############################################################################
158  // ############################################################################
160 
162 
163  MixedGraph& operator=(const MixedGraph& g);
164 
166 
167  // not virtual : it is a feature !!! :)
168  bool operator==(const MixedGraph& g) const;
169 
171 
172  // not virtual : it is a feature !!! :)
173  bool operator!=(const MixedGraph& g) const;
174 
176 
177  // ############################################################################
179  // ############################################################################
181 
183 
186  virtual void eraseNode(const NodeId id);
187 
189  virtual void clear();
190 
200  const std::vector< NodeId > mixedOrientedPath(const NodeId node1,
201  const NodeId node2) const;
202 
204 
210  const std::vector< NodeId > mixedUnorientedPath(const NodeId node1,
211  const NodeId node2) const;
212 
214  virtual const std::string toDot() const;
215 
217  virtual const std::string toString() const;
218 
220  };
221 
223  std::ostream& operator<<(std::ostream&, const MixedGraph&);
224 
225 } /* namespace gum */
226 
227 #ifndef GUM_NO_INLINE
229 #endif // GUM_NOINLINE
230 
231 #endif /* GUM_MIXEDGRAPH_H */
const std::vector< NodeId > mixedUnorientedPath(const NodeId node1, const NodeId node2) const
returns a mixed/directed path from node1 to node2 in the arc/edge set
Definition: mixedGraph.cpp:133
MixedGraph & operator=(const MixedGraph &g)
copy operator
virtual void clear()
removes all the nodes, arcs and edges from the graph
bool operator!=(const MixedGraph &g) const
tests whether two MixedGraphs are different
Base classes for oriented graphs.
virtual const std::string toString() const
to friendly display the content of the MixedGraph
Definition: mixedGraph.cpp:61
static constexpr Size default_size
The default number of slots in hashtables.
Definition: hashTable.h:77
Base classes for undirected graphs.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual void eraseNode(const NodeId id)
remove a node as well as its adjacent arcs and edges from the graph
virtual const std::string toDot() const
to friendly display mixed graph in DOT format
Definition: mixedGraph.cpp:214
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
Base class for all oriented graphs.
Definition: diGraph.h:108
bool operator==(const MixedGraph &g) const
tests whether two MixedGraphs are identical (same nodes, arcs and edges)
Inline implementation of Base classes for mixed graphs.
MixedGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true, Size edges_size=HashTableConst::default_size, bool edges_resize_policy=true)
default constructor
Definition: mixedGraph.cpp:34
Base class for undirected graphs.
Definition: undiGraph.h:106
const std::vector< NodeId > mixedOrientedPath(const NodeId node1, const NodeId node2) const
returns a mixed edge/directed arc path from node1 to node2 in the arc/edge set
Definition: mixedGraph.cpp:71
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Size NodeId
Type for node ids.
Definition: graphElements.h:97
virtual ~MixedGraph()
destructor
Definition: mixedGraph.cpp:56
Base class for mixed graphs.
Definition: mixedGraph.h:124