aGrUM  0.14.2
DAG_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 IDE parser
28 #include <agrum/core/exceptions.h>
29 #include <agrum/graphs/DAG.h>
30 
31 namespace gum {
32 
33  INLINE DAG& DAG::operator=(const DAG& g) {
34  // avoid self assignment
35  if (this != &g) { DiGraph::operator=(g); }
36 
37  return *this;
38  }
39 
40  INLINE void DAG::addArc(const NodeId tail, const NodeId head) {
41  if (__hasDirectedPath(head, tail)) {
42  GUM_ERROR(InvalidDirectedCycle, "Add a directed cycle in a dag !");
43  }
44 
45  // checking whether tail and head do belong to the graph is performed
46  // within class DiGraph
47  DiGraph::addArc(tail, head);
48  }
49 
50 } /* namespace gum */
DiGraph & operator=(const DiGraph &g)
copy operator
Definition: diGraph_inl.h:45
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:32
bool __hasDirectedPath(const NodeId from, const NodeId to)
checks whether there exists a directed path from from to to
Definition: DAG.cpp:54
DAG & operator=(const DAG &g)
copy operator
Definition: DAG_inl.h:33
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
aGrUM&#39;s exceptions
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: DAG_inl.h:40
Base class for dag.
Definition: DAG.h:99
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Base classes for directed acyclic graphs.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52