aGrUM  0.13.2
gum::prm::gspan::DFSCode Class Reference

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

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

Public Attributes

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

Public Member Functions

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

Static Public Member Functions

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

Public Types

typedef std::vector< EdgeCode * >::iterator iterator
 Code alias. More...
 
typedef std::vector< EdgeCode * >::const_iterator const_iterator
 Code alias. More...
 

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 50 of file DFSCode.h.

Member Typedef Documentation

Code alias.

Definition at line 128 of file DFSCode.h.

Code alias.

Definition at line 125 of file DFSCode.h.

Constructor & Destructor Documentation

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

Default constructor.

Create an empty DFSCode.

Definition at line 32 of file DFSCode_inl.h.

32 { GUM_CONSTRUCTOR(DFSCode); }
DFSCode()
Default constructor.
Definition: DFSCode_inl.h:32
INLINE gum::prm::gspan::DFSCode::DFSCode ( const DFSCode source)

Copy constructor.

Proceeds with a deep copy.

Definition at line 35 of file DFSCode_inl.h.

References codes.

35  {
36  GUM_CONS_CPY(DFSCode);
37 
38  for (const auto code : source.codes)
39  codes.push_back(new EdgeCode(*code));
40  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
DFSCode()
Default constructor.
Definition: DFSCode_inl.h:32
INLINE gum::prm::gspan::DFSCode::~DFSCode ( )

Destructor.

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

Definition at line 43 of file DFSCode_inl.h.

References codes.

43  {
44  GUM_DESTRUCTOR(DFSCode);
45 
46  for (const auto item : codes)
47  delete item;
48  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
DFSCode()
Default constructor.
Definition: DFSCode_inl.h:32

Member Function Documentation

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

References codes.

75  {
76  if (codes.size() == from.codes.size()) {
77  for (size_t idx = 0; idx < codes.size(); ++idx) {
78  if ((*codes[idx]) != (*codes[idx])) { return true; }
79  }
80 
81  return false;
82  } else {
83  return true;
84  }
85  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
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 88 of file DFSCode_inl.h.

References 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.

88  {
89  DFSCode::const_iterator iter = codes.begin();
90  DFSCode::const_iterator jter = from.codes.begin();
91 
92  for (; (iter != codes.end()) && (jter != from.codes.end());
93  ++iter, ++jter) {
94  if ((**iter) != (**jter)) {
95  EdgeCode& alpha = **iter;
96  EdgeCode& beta = **jter;
97 
98  if (alpha.isBackward()) {
99  if (beta.isForward()) {
100  return true;
101  } else if (alpha.j < beta.j) {
102  // beta is a backward edge
103  return true;
104  } else if ((alpha.j == beta.j) && (alpha.l_ij < beta.l_ij)) {
105  return true;
106  }
107 
108  return false;
109  } else {
110  // alpha is a forward edge
111  if (beta.isBackward()) {
112  return false;
113  } else if (beta.i < alpha.i) {
114  // Beta is a forward edge
115  return true;
116  } else if (beta.i == alpha.i) {
117  if (alpha.l_i < beta.l_i) {
118  return true;
119  } else if (alpha.l_i == beta.l_i) {
120  if (alpha.l_ij < beta.l_ij) {
121  return true;
122  } else if (alpha.l_ij == beta.l_ij) {
123  return alpha.l_j < beta.l_j;
124  }
125  }
126  }
127 
128  return false;
129  }
130 
131  return (**iter) < (**jter);
132  }
133  }
134 
135  return false;
136  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
std::vector< EdgeCode * >::const_iterator const_iterator
Code alias.
Definition: DFSCode.h:128

+ Here is the call graph for this function:

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

References codes.

139  {
140  DFSCode::const_iterator iter = codes.begin();
141  DFSCode::const_iterator jter = from.codes.begin();
142 
143  for (; (iter != codes.end()) && (jter != from.codes.end());
144  ++iter, ++jter) {
145  if ((**iter) != (**jter)) { return (**iter) < (**jter); }
146  }
147 
148  return codes.size() <= from.codes.size();
149  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
std::vector< EdgeCode * >::const_iterator const_iterator
Code alias.
Definition: DFSCode.h:128
INLINE DFSCode & gum::prm::gspan::DFSCode::operator= ( const DFSCode source)

Copy operator.

Proceeds with a deep copy.

Definition at line 51 of file DFSCode_inl.h.

References codes.

51  {
52  for (const auto item : codes)
53  delete item;
54 
55  for (const auto srcitem : source.codes)
56  codes.push_back(new EdgeCode(*srcitem));
57 
58  return *this;
59  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
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 62 of file DFSCode_inl.h.

References codes.

62  {
63  if (codes.size() == from.codes.size()) {
64  for (size_t idx = 0; idx < codes.size(); ++idx) {
65  if ((*codes[idx]) != (*codes[idx])) { return false; }
66  }
67 
68  return true;
69  } else {
70  return false;
71  }
72  }
std::vector< EdgeCode * > codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
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 139 of file DFSCode.h.

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().

139  {
140  if (e1->isBackward()) {
141  if (e2->isForward()) {
142  return (e2->i <= e1->i) && (e2->j = (e1->i + 1));
143  } else {
144  return (e2->i == e1->i) && (e1->j < e2->j);
145  }
146  } else {
147  // e1 is a forward edge
148  if (e2->isForward()) {
149  return (e2->i <= e1->j) && (e2->j == (e1->j + 1));
150  } else {
151  return (e2->i == e1->j) && (e2->j < e1->i);
152  }
153  }
154  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation


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