aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
DFSCode_inl.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41#pragma once
42
49
50#include <agrum/PRM/gspan/DFSCode.h> // to ease IDE parser
51
52namespace gum {
53 namespace prm {
54 namespace gspan {
55
56 INLINE
58 GUM_CONSTRUCTOR(DFSCode);
59 ;
60 }
61
62 INLINE
63 DFSCode::DFSCode(const DFSCode& source) {
64 GUM_CONS_CPY(DFSCode);
65
66 for (const auto code: source.codes)
67 codes.push_back(new EdgeCode(*code));
68 }
69
70 INLINE
72 GUM_DESTRUCTOR(DFSCode);
73
74 for (const auto item: codes)
75 delete item;
76 }
77
78 INLINE
80 for (const auto item: codes)
81 delete item;
82
83 for (const auto srcitem: source.codes)
84 codes.push_back(new EdgeCode(*srcitem));
85
86 return *this;
87 }
88
89 INLINE
90 bool DFSCode::operator<=(const DFSCode& from) const {
91 DFSCode::const_iterator iter = codes.begin();
92 DFSCode::const_iterator jter = from.codes.begin();
93
94 for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
95 if ((**iter) != (**jter)) { return (**iter) < (**jter); }
96 }
97
98 return codes.size() <= from.codes.size();
99 }
100
102 if (e1->isBackward()) {
103 if (e2->isForward()) {
104 return (e2->i <= e1->i) && (e2->j = (e1->i + 1));
105 } else {
106 return (e2->i == e1->i) && (e1->j < e2->j);
107 }
108 } else {
109 // e1 is a forward edge
110 if (e2->isForward()) {
111 return (e2->i <= e1->j) && (e2->j == (e1->j + 1));
112 } else {
113 return (e2->i == e1->j) && (e2->j < e1->i);
114 }
115 }
116 }
117
118 } /* namespace gspan */
119 } /* namespace prm */
120} /* namespace gum */
Headers of a DFSCode.
DFSCode & operator=(const DFSCode &source)
Copy operator.
Definition DFSCode_inl.h:79
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition DFSCode.h:109
std::vector< EdgeCode * >::const_iterator const_iterator
Code alias.
Definition DFSCode.h:150
bool operator<=(const DFSCode &code) const
Lesser or equal than operator.
Definition DFSCode_inl.h:90
DFSCode()
Default constructor.
Definition DFSCode_inl.h:57
static bool validNeighbors(EdgeCode *e1, EdgeCode *e2)
Returns true of e2 is a valid neighbor for e1 (i.e.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
represent a DFS code used by gspan.
Definition edgeCode.h:72
NodeId i
The DFS subscript of the first node in the code.
Definition edgeCode.h:97
bool isForward() const
Returns true if this EdgeCode is a forward edge.
NodeId j
The DFS subscript of the second node in the code.
Definition edgeCode.h:100
bool isBackward() const
Returns true if this EdgeCode is a backward edge.