aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::prm::gspan::DFSCode Class Reference

Reprensent a Depth First Search coding of a graph. More...

#include <agrum/PRM/gspan/DFSCode.h>

Public Types

using iterator = std::vector< EdgeCode* >::iterator
 Code alias.
using const_iterator = std::vector< EdgeCode* >::const_iterator
 Code alias.

Public Member Functions

 DFSCode ()
 Default constructor.
 DFSCode (const DFSCode &source)
 Copy constructor.
 ~DFSCode ()
 Destructor.
DFSCodeoperator= (const DFSCode &source)
 Copy operator.
bool operator== (const DFSCode &code) const
 Equality operator.
bool operator!= (const DFSCode &code) const
 Difference operator.
bool operator< (const DFSCode &code) const
 Lesser than operator.
bool operator<= (const DFSCode &code) const
 Lesser or equal than operator.

Static Public Member Functions

static bool validNeighbors (EdgeCode *e1, EdgeCode *e2)
 Returns true of e2 is a valid neighbor for e1 (i.e.

Public Attributes

std::vector< EdgeCode * > codes
 The vector containing the EdgeCode composing this DFSCode.

Detailed Description

Reprensent a Depth First Search coding of a graph.

A DFSCode is composed of EdgeCode. Each EdgeCode is either a forward edge or a backward edge.

Regarding memory allocation EdgeCode are shared between related DFSCode, so delete DFSCode in a bottom up fashion.

Definition at line 72 of file DFSCode.h.

Member Typedef Documentation

◆ const_iterator

using gum::prm::gspan::DFSCode::const_iterator = std::vector< EdgeCode* >::const_iterator

Code alias.

Definition at line 150 of file DFSCode.h.

◆ iterator

using gum::prm::gspan::DFSCode::iterator = std::vector< EdgeCode* >::iterator

Code alias.

Definition at line 147 of file DFSCode.h.

Constructor & Destructor Documentation

◆ DFSCode() [1/2]

INLINE gum::prm::gspan::DFSCode::DFSCode ( )

Default constructor.

Create an empty DFSCode.

Definition at line 54 of file DFSCode_inl.h.

54 {
55 GUM_CONSTRUCTOR(DFSCode);
56 ;
57 }
DFSCode()
Default constructor.
Definition DFSCode_inl.h:54

References DFSCode().

Referenced by DFSCode(), DFSCode(), ~DFSCode(), operator!=(), operator<(), operator<=(), operator=(), and operator==().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DFSCode() [2/2]

INLINE gum::prm::gspan::DFSCode::DFSCode ( const DFSCode & source)

Copy constructor.

Proceeds with a deep copy.

Definition at line 60 of file DFSCode_inl.h.

60 {
61 GUM_CONS_CPY(DFSCode);
62
63 for (const auto code: source.codes)
64 codes.push_back(new EdgeCode(*code));
65 }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition DFSCode.h:109

References DFSCode(), and codes.

Here is the call graph for this function:

◆ ~DFSCode()

INLINE gum::prm::gspan::DFSCode::~DFSCode ( )

Destructor.

This will delete all children of this DFSCode, with their respective EdgeCode.

Definition at line 68 of file DFSCode_inl.h.

68 {
69 GUM_DESTRUCTOR(DFSCode);
70
71 for (const auto item: codes)
72 delete item;
73 }

References DFSCode(), and codes.

Here is the call graph for this function:

Member Function Documentation

◆ operator!=()

INLINE bool gum::prm::gspan::DFSCode::operator!= ( const DFSCode & code) const

Difference operator.

Parameters
codeThe code tested for difference with this.
Returns
Returns true if this and code are different.

Definition at line 100 of file DFSCode_inl.h.

100 {
101 if (codes.size() == from.codes.size()) {
102 for (size_t idx = 0; idx < codes.size(); ++idx) {
103 if ((*codes[idx]) != (*codes[idx])) { return true; }
104 }
105
106 return false;
107 } else {
108 return true;
109 }
110 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ operator<()

INLINE bool gum::prm::gspan::DFSCode::operator< ( const DFSCode & code) const

Lesser than operator.

Parameters
codeThe code on which the test is made.
Returns
Returns true if this is lesser than code.

Definition at line 113 of file DFSCode_inl.h.

113 {
114 DFSCode::const_iterator iter = codes.begin();
115 DFSCode::const_iterator jter = from.codes.begin();
116
117 for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
118 if ((**iter) != (**jter)) {
119 EdgeCode& alpha = **iter;
120 EdgeCode& beta = **jter;
121
122 if (alpha.isBackward()) {
123 if (beta.isForward()) {
124 return true;
125 } else if (alpha.j < beta.j) {
126 // beta is a backward edge
127 return true;
128 } else if ((alpha.j == beta.j) && (alpha.l_ij < beta.l_ij)) {
129 return true;
130 }
131
132 return false;
133 } else {
134 // alpha is a forward edge
135 if (beta.isBackward()) {
136 return false;
137 } else if (beta.i < alpha.i) {
138 // Beta is a forward edge
139 return true;
140 } else if (beta.i == alpha.i) {
141 if (alpha.l_i < beta.l_i) {
142 return true;
143 } else if (alpha.l_i == beta.l_i) {
144 if (alpha.l_ij < beta.l_ij) {
145 return true;
146 } else if (alpha.l_ij == beta.l_ij) {
147 return alpha.l_j < beta.l_j;
148 }
149 }
150 }
151
152 return false;
153 }
154
155 return (**iter) < (**jter);
156 }
157 }
158
159 return false;
160 }
std::vector< EdgeCode * >::const_iterator const_iterator
Code alias.
Definition DFSCode.h:150

References DFSCode(), codes, gum::prm::gspan::EdgeCode::i, gum::prm::gspan::EdgeCode::isBackward(), gum::prm::gspan::EdgeCode::isForward(), gum::prm::gspan::EdgeCode::j, gum::prm::gspan::EdgeCode::l_i, gum::prm::gspan::EdgeCode::l_ij, and gum::prm::gspan::EdgeCode::l_j.

Here is the call graph for this function:

◆ operator<=()

INLINE bool gum::prm::gspan::DFSCode::operator<= ( const DFSCode & code) const

Lesser or equal than operator.

Parameters
codeThe code on which the test is made.
Returns
Returns true if this is lesser than code.

Definition at line 163 of file DFSCode_inl.h.

163 {
164 DFSCode::const_iterator iter = codes.begin();
165 DFSCode::const_iterator jter = from.codes.begin();
166
167 for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
168 if ((**iter) != (**jter)) { return (**iter) < (**jter); }
169 }
170
171 return codes.size() <= from.codes.size();
172 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ operator=()

INLINE DFSCode & gum::prm::gspan::DFSCode::operator= ( const DFSCode & source)

Copy operator.

Proceeds with a deep copy.

Definition at line 76 of file DFSCode_inl.h.

76 {
77 for (const auto item: codes)
78 delete item;
79
80 for (const auto srcitem: source.codes)
81 codes.push_back(new EdgeCode(*srcitem));
82
83 return *this;
84 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ operator==()

INLINE bool gum::prm::gspan::DFSCode::operator== ( const DFSCode & code) const

Equality operator.

Parameters
codeThe code tested for equality with this.
Returns
Returns true if this and code are equal.

Definition at line 87 of file DFSCode_inl.h.

87 {
88 if (codes.size() == from.codes.size()) {
89 for (size_t idx = 0; idx < codes.size(); ++idx) {
90 if ((*codes[idx]) != (*codes[idx])) { return false; }
91 }
92
93 return true;
94 } else {
95 return false;
96 }
97 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ validNeighbors()

bool gum::prm::gspan::DFSCode::validNeighbors ( EdgeCode * e1,
EdgeCode * e2 )
inlinestatic

Returns true of e2 is a valid neighbor for e1 (i.e.

it respect the neighborhood restriction) if e1 precedes e2 in a DFSCode.

Parameters
e1An EdgeCode.
e2Another EdgeCode.
Returns
Returns true of e2 is a valid neighbor for e1 (i.e. it respect the neighborhood restriction) if e1 precedes e2 in a DFSCode.

Definition at line 161 of file DFSCode.h.

161 {
162 if (e1->isBackward()) {
163 if (e2->isForward()) {
164 return (e2->i <= e1->i) && (e2->j = (e1->i + 1));
165 } else {
166 return (e2->i == e1->i) && (e1->j < e2->j);
167 }
168 } else {
169 // e1 is a forward edge
170 if (e2->isForward()) {
171 return (e2->i <= e1->j) && (e2->j == (e1->j + 1));
172 } else {
173 return (e2->i == e1->j) && (e2->j < e1->i);
174 }
175 }
176 }

References gum::prm::gspan::EdgeCode::i, gum::prm::gspan::EdgeCode::isBackward(), gum::prm::gspan::EdgeCode::isForward(), and gum::prm::gspan::EdgeCode::j.

Referenced by gum::prm::gspan::Pattern::addArc().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ codes


The documentation for this class was generated from the following files: