aGrUM 3.1.1
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 57 of file DFSCode_inl.h.

57 {
58 GUM_CONSTRUCTOR(DFSCode);
59 ;
60 }
DFSCode()
Default constructor.
Definition DFSCode_inl.h:57

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 63 of file DFSCode_inl.h.

63 {
64 GUM_CONS_CPY(DFSCode);
65
66 for (const auto code: source.codes)
67 codes.push_back(new EdgeCode(*code));
68 }
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 71 of file DFSCode_inl.h.

71 {
72 GUM_DESTRUCTOR(DFSCode);
73
74 for (const auto item: codes)
75 delete item;
76 }

References DFSCode(), and codes.

Here is the call graph for this function:

Member Function Documentation

◆ operator!=()

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 85 of file DFSCode.cpp.

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

References DFSCode(), and codes.

Here is the call graph for this function:

◆ operator<()

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 97 of file DFSCode.cpp.

97 {
98 DFSCode::const_iterator iter = codes.begin();
99 DFSCode::const_iterator jter = from.codes.begin();
100
101 for (; (iter != codes.end()) && (jter != from.codes.end()); ++iter, ++jter) {
102 if ((**iter) != (**jter)) {
103 EdgeCode& alpha = **iter;
104 EdgeCode& beta = **jter;
105
106 if (alpha.isBackward()) {
107 if (beta.isForward()) {
108 return true;
109 } else if (alpha.j < beta.j) {
110 // beta is a backward edge
111 return true;
112 } else if ((alpha.j == beta.j) && (alpha.l_ij < beta.l_ij)) {
113 return true;
114 }
115
116 return false;
117 } else {
118 // alpha is a forward edge
119 if (beta.isBackward()) {
120 return false;
121 } else if (beta.i < alpha.i) {
122 // Beta is a forward edge
123 return true;
124 } else if (beta.i == alpha.i) {
125 if (alpha.l_i < beta.l_i) {
126 return true;
127 } else if (alpha.l_i == beta.l_i) {
128 if (alpha.l_ij < beta.l_ij) {
129 return true;
130 } else if (alpha.l_ij == beta.l_ij) {
131 return alpha.l_j < beta.l_j;
132 }
133 }
134 }
135
136 return false;
137 }
138
139 return (**iter) < (**jter);
140 }
141 }
142
143 return false;
144 }
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 90 of file DFSCode_inl.h.

90 {
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 }

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 79 of file DFSCode_inl.h.

79 {
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 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ operator==()

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 73 of file DFSCode.cpp.

73 {
74 if (codes.size() == from.codes.size()) {
75 for (size_t idx = 0; idx < codes.size(); ++idx) {
76 if ((*codes[idx]) != (*codes[idx])) { return false; }
77 }
78
79 return true;
80 } else {
81 return false;
82 }
83 }

References DFSCode(), and codes.

Here is the call graph for this function:

◆ validNeighbors()

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

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 101 of file DFSCode_inl.h.

101 {
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 }

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: