aGrUM  0.14.2
edgeCode_inl.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 namespace gum {
28  namespace prm {
29  namespace gspan {
30 
31  INLINE
33  NodeId my_i, NodeId my_j, Size my_l_i, Size my_l_ij, Size my_l_j) :
34  i(my_i),
35  j(my_j), l_i(my_l_i), l_ij(my_l_ij), l_j(my_l_j) {
36  GUM_CONSTRUCTOR(EdgeCode);
37  std::stringstream sBuff;
38  sBuff << i << j << l_i << l_ij << l_j;
39  name = sBuff.str();
40  }
41 
42  INLINE
43  EdgeCode::EdgeCode(const EdgeCode& source) :
44  i(source.i), j(source.j), l_i(source.l_i), l_ij(source.l_ij),
45  l_j(source.l_j), name(source.name) {
46  GUM_CONS_CPY(EdgeCode);
47  }
48 
49  INLINE
50  EdgeCode::~EdgeCode() { GUM_DESTRUCTOR(EdgeCode); }
51 
52  INLINE
53  bool EdgeCode::isForward() const { return i < j; }
54 
55  INLINE
56  bool EdgeCode::isBackward() const { return i > j; }
57 
58  INLINE
60  i = source.i;
61  j = source.j;
62  l_i = source.l_i;
63  l_ij = source.l_ij;
64  l_j = source.l_j;
65  return *this;
66  }
67 
68  INLINE
69  bool EdgeCode::operator==(const EdgeCode& code) const {
70  return ((i == code.i) && (j == code.j) && (l_i == code.l_i)
71  && (l_ij == code.l_ij) && (l_j == code.l_j));
72  }
73 
74  INLINE
75  bool EdgeCode::operator!=(const EdgeCode& code) const {
76  return ((i != code.i) || (j != code.j) || (l_i != code.l_i)
77  || (l_ij != code.l_ij) || (l_j != code.l_j));
78  }
79 
80  INLINE
81  bool EdgeCode::operator<(const EdgeCode& code) const {
82  if ((i == code.i) && (j == code.j)) {
83  return (l_i < code.l_i) || ((l_i == code.l_i) && (l_ij < code.l_ij))
84  || ((l_i == code.l_i) && (l_ij == code.l_ij) && (l_j < code.l_j));
85  } else {
86  return ((i == code.i) && (j < code.j))
87  || ((i < code.j) && (j == code.i));
88  }
89  }
90 
91  } // namespace gspan
92  } // namespace prm
93 } // namespace gum
NodeId i
The DFS subscript of the first node in the code.
Definition: edgeCode.h:74
bool operator!=(const EdgeCode &code) const
Difference operator.
Definition: edgeCode_inl.h:75
NodeId j
The DFS subscript of the second node in the code.
Definition: edgeCode.h:77
Size l_ij
The label of the edge in the code.
Definition: edgeCode.h:83
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
represent a DFS code used by gspan.
Definition: edgeCode.h:49
bool isBackward() const
Returns true if this EdgeCode is a backward edge.
Definition: edgeCode_inl.h:56
bool operator<(const EdgeCode &code) const
Lesser than operator.
Definition: edgeCode_inl.h:81
bool operator==(const EdgeCode &code) const
Equality operator.
Definition: edgeCode_inl.h:69
std::string name
The string version of this EdgeCode.
Definition: edgeCode.h:89
EdgeCode(NodeId i, NodeId j, Size l_i, Size l_ij, Size l_j)
Default constructor.
Definition: edgeCode_inl.h:32
Size l_j
The label of the second node in the code.
Definition: edgeCode.h:86
bool isForward() const
Returns true if this EdgeCode is a forward edge.
Definition: edgeCode_inl.h:53
EdgeCode & operator=(const EdgeCode &source)
Copy operator.
Definition: edgeCode_inl.h:59
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Size NodeId
Type for node ids.
Definition: graphElements.h:97
Size l_i
The label of the first node in the code.
Definition: edgeCode.h:80