45#ifndef DOXYGEN_SHOULD_SKIP_THIS
52 template <
typename GS1,
typename GS2 >
54 if (ref.size() != test.size()) {
GUM_ERROR(OperationNotAllowed,
"Graphs of different sizes") }
55 for (
const NodeId node: ref.internalDag().asNodeSet()) {
56 if (!test.exists(ref.variable(node).name())) {
57 GUM_ERROR(InvalidNode,
"Test doesn't contain node " << node <<
" from ref")
63 BayesNet< GS2 > aligned_test;
64 for (
const NodeId id: ref.internalDag().asNodeSet()) {
65 aligned_test.add(ref.variable(
id),
id);
67 for (
const Arc& arc: test.internalDag().arcs()) {
68 const NodeId tail = ref.idFromName(test.variable(arc.tail()).name());
69 const NodeId head = ref.idFromName(test.variable(arc.head()).name());
70 aligned_test.addArc(tail, head);
73 PDAG ref_eg = EssentialGraph(ref).pdag();
74 PDAG test_eg = EssentialGraph(aligned_test).pdag();
78 template < GUM_Numeric GUM_SCALAR >
80 PDAG ref_eg = EssentialGraph(ref).pdag();
84 template < GUM_Numeric GUM_SCALAR >
86 PDAG test_eg = EssentialGraph(test).pdag();
91 template <
typename GS1,
typename GS2 >
93 if (ref.size() != test.size()) {
GUM_ERROR(OperationNotAllowed,
"Graphs of different sizes") }
94 for (
const NodeId node: ref.internalDag().asNodeSet()) {
95 if (!test.exists(ref.variable(node).name())) {
96 GUM_ERROR(InvalidNode,
"Test doesn't contain node " << node <<
" from ref")
102 for (
const NodeId id: ref.internalDag().asNodeSet()) {
103 aligned_test.addNodeWithId(
id);
105 for (
const Arc& arc: test.internalDag().arcs()) {
106 const NodeId tail = ref.idFromName(test.variable(arc.tail()).name());
107 const NodeId head = ref.idFromName(test.variable(arc.head()).name());
108 aligned_test.addArc(tail, head);
110 return this->
sid(ref.internalDag(), aligned_test);
Base classes for partially directed acyclic graphs.
Class representing a Bayesian network.
Base class for partially directed acyclic graphs.
void compare(const DiGraph &ref, const DiGraph &test)
compare two DiGraphs (nodes matched by NodeId, no alignment)
double sid(const DAG &ref, const DAG &test) const
Confusion matrix.
Class building the essential Graph from a DAGmodel.
#define GUM_ERROR(type, msg)
Size NodeId
Type for node ids.
gum is the global namespace for all aGrUM entities
A class for comparing graphs based on their structures.