aGrUM  0.17.2
a C++ library for (probabilistic) graphical models
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>
37 
40 
41 namespace gum {
42 
43  /* ===========================================================================
44  */
45  /* === BASE CLASS FOR MANIPULATING ALL DIRECTED GRAPHS ===
46  */
47  /* ===========================================================================
48  */
109  /* ===========================================================================
110  */
111  class DiGraph: public virtual NodeGraphPart, public ArcGraphPart {
112  public:
113  // ############################################################################
115  // ############################################################################
117 
119 
123  explicit DiGraph(Size nodes_size = HashTableConst::default_size,
124  bool nodes_resize_policy = true,
126  bool arcs_resize_policy = true);
127 
129 
130  DiGraph(const DiGraph& g);
131 
133  virtual ~DiGraph();
134 
136 
137  // ############################################################################
139  // ############################################################################
141 
143 
144  DiGraph& operator=(const DiGraph& g);
145 
147 
148  // not virtual : it is a feature !!! :)
149  bool operator==(const DiGraph& g) const;
150 
152 
153  // not virtual : it is a feature !!! :)
154  bool operator!=(const DiGraph& g) const;
155 
157 
158  // ############################################################################
160  // ############################################################################
162 
164 
169  virtual void addArc(const NodeId tail, const NodeId head);
170 
172 
175  virtual void eraseNode(const NodeId id);
176 
178  virtual void clear();
179 
181  virtual const std::string toString() const;
182 
184 
186  virtual const std::string toDot() const;
187 
194  const Sequence< NodeId >& topologicalOrder(bool clear = true) const;
196 
206  bool hasDirectedPath(const NodeId from, const NodeId to);
207 
208  private:
211 
214  void __topologicalOrder() const;
215  };
216 
218  std::ostream& operator<<(std::ostream&, const DiGraph&);
219 
220 } /* namespace gum */
221 
222 #ifndef GUM_NO_INLINE
224 #endif // GUM_NOINLINE
225 
226 #endif /* GUM_DIGRAPH_H */
DiGraph & operator=(const DiGraph &g)
copy operator
Definition: diGraph_inl.h:48
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
Definition: agrum.h:25
Sequence< NodeId > * __mutableTopologicalOrder
The topology sequence of this Directed Graphical Model.
Definition: diGraph.h:210
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
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-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
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