aGrUM  0.13.2
structuralComparator_tpl.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}@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 wil 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  ***************************************************************************/
20 
21 #ifndef DOXYGEN_SHOULD_SKIP_THIS
22 
24 # include <agrum/graphs/mixedGraph.h>
25 
26 namespace gum {
27 
28  template < typename GS1, typename GS2 >
29  void StructuralComparator::compare(const BayesNet< GS1 >& ref,
30  const BayesNet< GS2 >& test) {
31  if (ref.size() != test.size()) {
32  GUM_ERROR(OperationNotAllowed, "Graphs of different sizes");
33  }
34  for (const NodeId node : ref.dag().asNodeSet()) {
35  if (!test.dag().existsNode(node)) {
36  GUM_ERROR(InvalidNode,
37  "Test doesn't contain node " << node << " from ref");
38  }
39  }
40 
41  MixedGraph ref_eg = EssentialGraph(ref).mixedGraph();
42  MixedGraph test_eg = EssentialGraph(test).mixedGraph();
43 
44  this->compare(ref_eg, test_eg);
45  }
46 
47  template < typename GUM_SCALAR >
48  void StructuralComparator::compare(const BayesNet< GUM_SCALAR >& ref,
49  const MixedGraph& test) {
50  MixedGraph ref_eg = EssentialGraph(ref).mixedGraph();
51  this->compare(ref_eg, test);
52  }
53 
54  template < typename GUM_SCALAR >
55  void StructuralComparator::compare(const MixedGraph& ref,
56  const BayesNet< GUM_SCALAR >& test) {
57  MixedGraph test_eg = EssentialGraph(test).mixedGraph();
58 
59  this->compare(ref, test_eg);
60  }
61 } /* namespace gum */
62 
63 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Class building the essential Graph from a DAGmodel.
void compare(const DiGraph &ref, const DiGraph &test)
compare two DiGraphs
Base classes for mixed directed/undirected graphs.
#define GUM_ERROR(type, msg)
Definition: exceptions.h:66