aGrUM  0.14.2
DFSCode.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 #include <ostream>
28 #include <vector>
29 
31 
32 #ifndef GUM_DFS_CODE_H
33 # define GUM_DFS_CODE_H
34 
35 namespace gum {
36  namespace prm {
37  namespace gspan {
38 
50  class DFSCode {
51  public:
62  static bool validNeighbors(EdgeCode* e1, EdgeCode* e2);
63 
68  DFSCode();
69 
75  DFSCode(const DFSCode& source);
76 
82  ~DFSCode();
83 
87  std::vector< EdgeCode* > codes;
88 
94  DFSCode& operator=(const DFSCode& source);
95 
101  bool operator==(const DFSCode& code) const;
102 
108  bool operator!=(const DFSCode& code) const;
109 
115  bool operator<(const DFSCode& code) const;
116 
122  bool operator<=(const DFSCode& code) const;
123 
125  typedef std::vector< EdgeCode* >::iterator iterator;
126 
128  typedef std::vector< EdgeCode* >::const_iterator const_iterator;
129  };
130 
137  std::ostream& operator<<(std::ostream& out, const DFSCode& code);
138 
139  inline bool DFSCode::validNeighbors(EdgeCode* e1, EdgeCode* e2) {
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  }
155 
156  } /* namespace gspan */
157  } /* namespace prm */
158 } /* namespace gum */
159 
160 # ifndef GUM_NO_INLINE
162 # endif // GUM_NO_INLINE
163 
164 #endif /* GUM_DFS_CODE_H */
bool operator<(const DFSCode &code) const
Lesser than operator.
Definition: DFSCode_inl.h:88
Inline implementation of the DFSCode class.
NodeId i
The DFS subscript of the first node in the code.
Definition: edgeCode.h:74
std::ostream & operator<<(std::ostream &out, const DFSCode &code)
Print code in out.
Definition: DFSCode.cpp:37
bool operator==(const DFSCode &code) const
Equality operator.
Definition: DFSCode_inl.h:62
bool operator<=(const DFSCode &code) const
Lesser or equal than operator.
Definition: DFSCode_inl.h:139
NodeId j
The DFS subscript of the second node in the code.
Definition: edgeCode.h:77
Reprensent a Depth First Search coding of a graph.
Definition: DFSCode.h:50
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
DFSCode & operator=(const DFSCode &source)
Copy operator.
Definition: DFSCode_inl.h:51
std::vector< EdgeCode *> codes
The vector containing the EdgeCode composing this DFSCode.
Definition: DFSCode.h:87
represent a DFS code used by gspan.
Definition: edgeCode.h:49
Headers of the EdgeCode class.
bool isBackward() const
Returns true if this EdgeCode is a backward edge.
Definition: edgeCode_inl.h:56
bool operator!=(const DFSCode &code) const
Difference operator.
Definition: DFSCode_inl.h:75
bool isForward() const
Returns true if this EdgeCode is a forward edge.
Definition: edgeCode_inl.h:53
DFSCode()
Default constructor.
Definition: DFSCode_inl.h:32
static bool validNeighbors(EdgeCode *e1, EdgeCode *e2)
Returns true of e2 is a valid neighbor for e1 (i.e.
Definition: DFSCode.h:139
std::vector< EdgeCode *>::iterator iterator
Code alias.
Definition: DFSCode.h:125
~DFSCode()
Destructor.
Definition: DFSCode_inl.h:43
std::vector< EdgeCode *>::const_iterator const_iterator
Code alias.
Definition: DFSCode.h:128