aGrUM  0.16.0
DFSCode.h
Go to the documentation of this file.
1 
30 #include <ostream>
31 #include <vector>
32 
34 
35 #ifndef GUM_DFS_CODE_H
36 # define GUM_DFS_CODE_H
37 
38 namespace gum {
39  namespace prm {
40  namespace gspan {
41 
53  class DFSCode {
54  public:
65  static bool validNeighbors(EdgeCode* e1, EdgeCode* e2);
66 
71  DFSCode();
72 
78  DFSCode(const DFSCode& source);
79 
85  ~DFSCode();
86 
90  std::vector< EdgeCode* > codes;
91 
97  DFSCode& operator=(const DFSCode& source);
98 
104  bool operator==(const DFSCode& code) const;
105 
111  bool operator!=(const DFSCode& code) const;
112 
118  bool operator<(const DFSCode& code) const;
119 
125  bool operator<=(const DFSCode& code) const;
126 
128  typedef std::vector< EdgeCode* >::iterator iterator;
129 
131  typedef std::vector< EdgeCode* >::const_iterator const_iterator;
132  };
133 
140  std::ostream& operator<<(std::ostream& out, const DFSCode& code);
141 
142  inline bool DFSCode::validNeighbors(EdgeCode* e1, EdgeCode* e2) {
143  if (e1->isBackward()) {
144  if (e2->isForward()) {
145  return (e2->i <= e1->i) && (e2->j = (e1->i + 1));
146  } else {
147  return (e2->i == e1->i) && (e1->j < e2->j);
148  }
149  } else {
150  // e1 is a forward edge
151  if (e2->isForward()) {
152  return (e2->i <= e1->j) && (e2->j == (e1->j + 1));
153  } else {
154  return (e2->i == e1->j) && (e2->j < e1->i);
155  }
156  }
157  }
158 
159  } /* namespace gspan */
160  } /* namespace prm */
161 } /* namespace gum */
162 
163 # ifndef GUM_NO_INLINE
165 # endif // GUM_NO_INLINE
166 
167 #endif /* GUM_DFS_CODE_H */
bool operator<(const DFSCode &code) const
Lesser than operator.
Definition: DFSCode_inl.h:91
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeId i
The DFS subscript of the first node in the code.
Definition: edgeCode.h:77
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
Definition: DFSCode.cpp:40
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
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
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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
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
static bool validNeighbors(EdgeCode *e1, EdgeCode *e2)
Returns true of e2 is a valid neighbor for e1 (i.e.
Definition: DFSCode.h:142
std::vector< EdgeCode *>::iterator iterator
Code alias.
Definition: DFSCode.h:128
~DFSCode()
Destructor.
Definition: DFSCode_inl.h:46
std::vector< EdgeCode *>::const_iterator const_iterator
Code alias.
Definition: DFSCode.h:131