aGrUM  0.16.0
DFSCode_inl.h
Go to the documentation of this file.
1 
30 namespace gum {
31  namespace prm {
32  namespace gspan {
33 
34  INLINE
35  DFSCode::DFSCode() { GUM_CONSTRUCTOR(DFSCode); }
36 
37  INLINE
38  DFSCode::DFSCode(const DFSCode& source) {
39  GUM_CONS_CPY(DFSCode);
40 
41  for (const auto code : source.codes)
42  codes.push_back(new EdgeCode(*code));
43  }
44 
45  INLINE
47  GUM_DESTRUCTOR(DFSCode);
48 
49  for (const auto item : codes)
50  delete item;
51  }
52 
53  INLINE
55  for (const auto item : codes)
56  delete item;
57 
58  for (const auto srcitem : source.codes)
59  codes.push_back(new EdgeCode(*srcitem));
60 
61  return *this;
62  }
63 
64  INLINE
65  bool DFSCode::operator==(const DFSCode& from) const {
66  if (codes.size() == from.codes.size()) {
67  for (size_t idx = 0; idx < codes.size(); ++idx) {
68  if ((*codes[idx]) != (*codes[idx])) { return false; }
69  }
70 
71  return true;
72  } else {
73  return false;
74  }
75  }
76 
77  INLINE
78  bool DFSCode::operator!=(const DFSCode& from) const {
79  if (codes.size() == from.codes.size()) {
80  for (size_t idx = 0; idx < codes.size(); ++idx) {
81  if ((*codes[idx]) != (*codes[idx])) { return true; }
82  }
83 
84  return false;
85  } else {
86  return true;
87  }
88  }
89 
90  INLINE
91  bool DFSCode::operator<(const DFSCode& from) const {
92  DFSCode::const_iterator iter = codes.begin();
93  DFSCode::const_iterator jter = from.codes.begin();
94 
95  for (; (iter != codes.end()) && (jter != from.codes.end());
96  ++iter, ++jter) {
97  if ((**iter) != (**jter)) {
98  EdgeCode& alpha = **iter;
99  EdgeCode& beta = **jter;
100 
101  if (alpha.isBackward()) {
102  if (beta.isForward()) {
103  return true;
104  } else if (alpha.j < beta.j) {
105  // beta is a backward edge
106  return true;
107  } else if ((alpha.j == beta.j) && (alpha.l_ij < beta.l_ij)) {
108  return true;
109  }
110 
111  return false;
112  } else {
113  // alpha is a forward edge
114  if (beta.isBackward()) {
115  return false;
116  } else if (beta.i < alpha.i) {
117  // Beta is a forward edge
118  return true;
119  } else if (beta.i == alpha.i) {
120  if (alpha.l_i < beta.l_i) {
121  return true;
122  } else if (alpha.l_i == beta.l_i) {
123  if (alpha.l_ij < beta.l_ij) {
124  return true;
125  } else if (alpha.l_ij == beta.l_ij) {
126  return alpha.l_j < beta.l_j;
127  }
128  }
129  }
130 
131  return false;
132  }
133 
134  return (**iter) < (**jter);
135  }
136  }
137 
138  return false;
139  }
140 
141  INLINE
142  bool DFSCode::operator<=(const DFSCode& from) const {
143  DFSCode::const_iterator iter = codes.begin();
144  DFSCode::const_iterator jter = from.codes.begin();
145 
146  for (; (iter != codes.end()) && (jter != from.codes.end());
147  ++iter, ++jter) {
148  if ((**iter) != (**jter)) { return (**iter) < (**jter); }
149  }
150 
151  return codes.size() <= from.codes.size();
152  }
153 
154  } /* namespace gspan */
155  } /* namespace prm */
156 } /* namespace gum */
bool operator<(const DFSCode &code) const
Lesser than operator.
Definition: DFSCode_inl.h:91
NodeId i
The DFS subscript of the first node in the code.
Definition: edgeCode.h:77
bool operator==(const DFSCode &code) const
Equality operator.
Definition: DFSCode_inl.h:65
bool operator<=(const DFSCode &code) const
Lesser or equal than operator.
Definition: DFSCode_inl.h:142
NodeId j
The DFS subscript of the second node in the code.
Definition: edgeCode.h:80
Reprensent a Depth First Search coding of a graph.
Definition: DFSCode.h:53
Size l_ij
The label of the edge in the code.
Definition: edgeCode.h:86
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
DFSCode & operator=(const DFSCode &source)
Copy operator.
Definition: DFSCode_inl.h:54
std::vector< EdgeCode *> codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:90
represent a DFS code used by gspan.
Definition: edgeCode.h:52
bool isBackward() const
Returns true if this EdgeCode is a backward edge.
Definition: edgeCode_inl.h:59
bool operator!=(const DFSCode &code) const
Difference operator.
Definition: DFSCode_inl.h:78
Size l_j
The label of the second node in the code.
Definition: edgeCode.h:89
bool isForward() const
Returns true if this EdgeCode is a forward edge.
Definition: edgeCode_inl.h:56
DFSCode()
Default constructor.
Definition: DFSCode_inl.h:35
~DFSCode()
Destructor.
Definition: DFSCode_inl.h:46
std::vector< EdgeCode *>::const_iterator const_iterator
Code alias.
Definition: DFSCode.h:131
Size l_i
The label of the first node in the code.
Definition: edgeCode.h:83