aGrUM  0.14.2
diGraph_inl.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  ***************************************************************************/
27 // to ease parser in IDEs
28 #include <agrum/graphs/diGraph.h>
29 
30 namespace gum {
31 
32  INLINE void DiGraph::addArc(const NodeId tail, const NodeId head) {
33  if (!exists(head)) { GUM_ERROR(InvalidNode, "head node"); }
34 
35  if (!exists(tail)) { GUM_ERROR(InvalidNode, "tail node"); }
36 
37  ArcGraphPart::addArc(tail, head);
38  }
39 
40  INLINE void DiGraph::clear() {
43  }
44 
45  INLINE DiGraph& DiGraph::operator=(const DiGraph& g) {
46  // avoid self assigment
47  if (this != &g) {
51 
52  if (__mutableTopologicalOrder != nullptr) {
54  __mutableTopologicalOrder = nullptr;
55  }
56 
57  if (g.__mutableTopologicalOrder != nullptr) {
60  }
61  }
62 
63  return *this;
64  }
65 
66  INLINE void DiGraph::eraseNode(const NodeId id) {
67  // warning: to remove the arcs adjacent to id, use the unvirtualized
68  // versions
69  // of arc removals
72 
74  }
75 
76  INLINE bool DiGraph::operator==(const DiGraph& p) const {
78  }
79 
80  INLINE bool DiGraph::operator!=(const DiGraph& p) const {
81  return !operator==(p);
82  }
83 
84 } /* namespace gum */
DiGraph & operator=(const DiGraph &g)
copy operator
Definition: diGraph_inl.h:45
NodeGraphPart & operator=(const NodeGraphPart &p)
copy operator
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:32
Base classes for oriented graphs.
bool operator!=(const DiGraph &g) const
tests whether two DiGraphs are different
Definition: diGraph_inl.h:80
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the ArcGraphPart
ArcGraphPart & operator=(const ArcGraphPart &s)
copy operator
void clearArcs()
removes all the arcs from the ArcGraphPart
virtual void clear()
removes all the nodes and arcs from the graph
Definition: diGraph_inl.h:40
bool exists(const NodeId id) const
alias for existsNode
bool operator==(const DiGraph &g) const
tests whether two DiGraphs are identical (same nodes, same arcs)
Definition: diGraph_inl.h:76
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
bool operator==(const NodeGraphPart &p) const
check whether two NodeGraphParts contain the same nodes
Sequence< NodeId > * __mutableTopologicalOrder
The topology sequence of this Directed Graphical Model.
Definition: diGraph.h:198
bool operator==(const ArcGraphPart &p) const
tests whether two ArcGraphParts contain the same arcs
Base class for all oriented graphs.
Definition: diGraph.h:108
virtual void clearNodes()
remove all the nodes from the NodeGraphPart
void unvirtualizedEraseChildren(const NodeId id)
same function as eraseChildren but without any virtual call to an erase
void unvirtualizedEraseParents(const NodeId id)
same function as eraseParents but without any virtual call to an erase
virtual void eraseNode(const NodeId id)
remove a node and its adjacent arcs from the graph
Definition: diGraph_inl.h:66
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
virtual void eraseNode(const NodeId id)
erase the node with the given id