aGrUM  0.16.0
diGraph.h
Go to the documentation of this file.
1 
28 #ifndef GUM_DIGRAPH_H
29 #define GUM_DIGRAPH_H
30 
31 #include <iostream>
32 #include <sstream>
33 #include <utility>
34 
35 #include <agrum/agrum.h>
36 #include <agrum/core/sequence.h>
37 
40 
41 namespace gum {
42 
43  /* ===========================================================================
44  */
45  /* === BASE CLASS FOR MANIPULATING ALL DIRECTED GRAPHS ===
46  */
47  /* ===========================================================================
48  */
109  /* ===========================================================================
110  */
111  class DiGraph
112  : public virtual NodeGraphPart
113  , public ArcGraphPart {
114  public:
115  // ############################################################################
117  // ############################################################################
119 
121 
125  explicit DiGraph(Size nodes_size = HashTableConst::default_size,
126  bool nodes_resize_policy = true,
128  bool arcs_resize_policy = true);
129 
131 
132  DiGraph(const DiGraph& g);
133 
135  virtual ~DiGraph();
136 
138 
139  // ############################################################################
141  // ############################################################################
143 
145 
146  DiGraph& operator=(const DiGraph& g);
147 
149 
150  // not virtual : it is a feature !!! :)
151  bool operator==(const DiGraph& g) const;
152 
154 
155  // not virtual : it is a feature !!! :)
156  bool operator!=(const DiGraph& g) const;
157 
159 
160  // ############################################################################
162  // ############################################################################
164 
166 
171  virtual void addArc(const NodeId tail, const NodeId head);
172 
174 
177  virtual void eraseNode(const NodeId id);
178 
180  virtual void clear();
181 
183  virtual const std::string toString() const;
184 
186 
188  virtual const std::string toDot() const;
189 
196  const Sequence< NodeId >& topologicalOrder(bool clear = true) const;
198 
208  bool hasDirectedPath(const NodeId from, const NodeId to);
209 
210  private:
213 
216  void __topologicalOrder() const;
217  };
218 
220  std::ostream& operator<<(std::ostream&, const DiGraph&);
221 
222 } /* namespace gum */
223 
224 #ifndef GUM_NO_INLINE
225 # include <agrum/graphs/diGraph_inl.h>
226 #endif // GUM_NOINLINE
227 
228 #endif /* GUM_DIGRAPH_H */
DiGraph & operator=(const DiGraph &g)
copy operator
Definition: diGraph_inl.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:35
bool operator!=(const DiGraph &g) const
tests whether two DiGraphs are different
Definition: diGraph_inl.h:83
DiGraph(Size nodes_size=HashTableConst::default_size, bool nodes_resize_policy=true, Size arcs_size=HashTableConst::default_size, bool arcs_resize_policy=true)
default constructor
Definition: diGraph.cpp:37
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Classes for directed edge sets.
Definition: arcGraphPart.h:79
virtual void clear()
removes all the nodes and arcs from the graph
Definition: diGraph_inl.h:43
virtual const std::string toString() const
to friendly display the content of the graph
Definition: diGraph.cpp:61
static constexpr Size default_size
The default number of slots in hashtables.
Definition: hashTable.h:80
virtual ~DiGraph()
destructor
Definition: diGraph.cpp:56
bool operator==(const DiGraph &g) const
tests whether two DiGraphs are identical (same nodes, same arcs)
Definition: diGraph_inl.h:79
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Sequence< NodeId > * __mutableTopologicalOrder
The topology sequence of this Directed Graphical Model.
Definition: diGraph.h:212
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
Base class for all oriented graphs.
Definition: diGraph.h:111
virtual const std::string toDot() const
to friendly display the content of the graph in the DOT syntax
Definition: diGraph.cpp:68
Class for node sets in graph.
const Sequence< NodeId > & topologicalOrder(bool clear=true) const
The topological order stays the same as long as no variable or arcs are added or erased src the topol...
Definition: diGraph.cpp:91
bool hasDirectedPath(const NodeId from, const NodeId to)
checks whether there exists a directed path from from to to
Definition: diGraph.cpp:137
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:69
Size NodeId
Type for node ids.
Definition: graphElements.h:98
void __topologicalOrder() const
Returns a topological order of this DAGModel.
Definition: diGraph.cpp:108