aGrUM  0.14.2
pattern.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 #ifndef GUM_PATTERN_H
28 #define GUM_PATTERN_H
29 
30 #include <agrum/agrum.h>
31 
32 #include <agrum/graphs/diGraph.h>
33 
36 
37 namespace gum {
38  namespace prm {
39  namespace gspan {
40 
41  class NeighborIterator;
42 
70  class Pattern : private DiGraph {
71  public:
72  // =========================================================================
74  // ==========================================================================
76 
78  Pattern();
79 
81  Pattern(const Pattern& source);
82 
84  ~Pattern();
85 
87  // =========================================================================
89  // ==========================================================================
91 
97 
99  LabelData& label(NodeId node);
100 
102  const LabelData& label(NodeId node) const;
103 
105  LabelData& label(NodeId i, NodeId j);
106 
108  const LabelData& label(NodeId i, NodeId j) const;
109 
111  LabelData& label(const Arc& arc);
112 
114  const LabelData& label(const Arc& arc) const;
115 
116  // Returns the last added LabelData.
117  LabelData& lastAdded();
118 
119  // Returns the last added LabelData.
120  const LabelData& lastAdded() const;
121 
135  void addArc(NodeId i, NodeId j, LabelData& l);
136 
138  bool exists(NodeId id) const;
139 
141  bool exists(NodeId tail, NodeId head) const;
142 
144  Size size() const;
145 
147  Size sizeArcs() const;
148 
151  void rightmostPath(std::list< NodeId >& r_path) const;
152 
154  std::string toDot(size_t name) const;
155 
157  // =========================================================================
159  // ==========================================================================
161  const NodeGraphPart& nodes() const;
162 
163  const ArcSet& arcs() const;
164 
166  // =========================================================================
168  // ==========================================================================
170 
172  DFSCode& code();
173 
175  const DFSCode& code() const;
176 
178  EdgeCode& edgeCode(NodeId tail, NodeId head);
179 
181  EdgeCode& edgeCode(const Arc& arc);
182 
184  const EdgeCode& edgeCode(NodeId tail, NodeId head) const;
185 
187  const EdgeCode& edgeCode(const Arc& arc) const;
188 
190  void pop_back();
191 
194  void remove(NodeId node);
195 
196  bool isMinimal();
197 
199 
200  private:
203 
207 
211 
214 
226 
233  bool __rec(Pattern& p,
234  Bijection< NodeId, NodeId >& node_map,
235  NodeId u,
236  NodeId v);
237 
239  bool __not_rec(Pattern& p,
240  Bijection< NodeId, NodeId >& node_map,
241  NodeId u,
242  NodeId v);
243 
244  // to avoid clang++ warnings
245  using DiGraph::addNode;
246  using DiGraph::addArc;
247  using DiGraph::toDot;
248  using DiGraph::parents;
249  using DiGraph::children;
250  };
251  } /* namespace gspan */
252  } /* namespace prm */
253 } /* namespace gum */
254 #ifndef GUM_NO_INLINE
256 #endif // GUM_NO_INLINE
257 
258 #endif /* GUM_PATTERN_H */
EdgeCode & edgeCode(NodeId tail, NodeId head)
Returns the EdgeCode of an edge of this Pattern.
Definition: pattern_inl.h:176
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:32
Base classes for oriented graphs.
Inner class to handle data about labels in this interface graph.
Pattern()
Default constructor.
Definition: pattern_inl.h:32
ArcProperty< std::pair< LabelData *, EdgeCode *> > __arc_map
Mapping between edges in this Pattern and their respective LabelData.
Definition: pattern.h:210
DFSCode & code()
Returns the DFSCode of this Pattern.
Definition: pattern_inl.h:170
NodeId addNodeWithLabel(LabelData &l)
Insert a node with the given LabelData.
Definition: pattern_inl.h:38
bool __expandCodeIsMinimal(NodeId u, NodeId v)
Returns true if the expand code by adding and edge betwenne u and v is minimal with respect to __code...
Definition: pattern.cpp:96
Reprensent a Depth First Search coding of a graph.
Definition: DFSCode.h:50
bool isMinimal()
Returns the DFSCode of this Pattern.
Definition: pattern.cpp:53
~Pattern()
Destructor.
Definition: pattern_inl.h:35
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual NodeId addNode()
insert a new node and return its id
The class for generic Hash Tables.
Definition: hashTable.h:676
LabelData & label(NodeId node)
Returns the LabelData assigned to node.
Definition: pattern_inl.h:47
represent a DFS code used by gspan.
Definition: edgeCode.h:49
Size size() const
Returns the number of nodes in this Pattern.
Definition: pattern_inl.h:144
The base class for all directed edgesThis class is used as a basis for manipulating all directed edge...
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
Base class for all oriented graphs.
Definition: diGraph.h:108
NodeProperty< LabelData *> __node_map
Mapping between nodes in this Pattern and their respective LabelData.
Definition: pattern.h:206
virtual const std::string toDot() const
to friendly display the content of the graph in the DOT syntax
Definition: diGraph.cpp:65
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
bool __not_rec(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
A non recursive bugged version of __rec.
Definition: pattern.cpp:186
Class for node sets in graph.
LabelData & lastAdded()
Insert a node with the given LabelData.
Definition: pattern_inl.h:65
const NodeGraphPart & nodes() const
Definition: pattern_inl.h:163
void rightmostPath(std::list< NodeId > &r_path) const
Fill r_path with the rightmost path of this Pattern. The list is supposed empty.
Definition: pattern_inl.h:150
LabelData * __last
The last LabelData added to this pattern.
Definition: pattern.h:213
const ArcSet & arcs() const
Definition: pattern_inl.h:167
bool __rec(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
Recurisve method used by __expandCodeIsMinimal.
Definition: pattern.cpp:125
void pop_back()
Remove the last EdgeCode of this pattern.
Definition: pattern_inl.h:204
Inline implementation of the Pattern class.
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
DFSCode __code
The DFSCode of this Pattern.
Definition: pattern.h:202
Headers of InterfaceGraph.
void addArc(NodeId i, NodeId j, LabelData &l)
Add an arc to this Pattern.
Definition: pattern_inl.h:115
bool exists(NodeId id) const
Returns true if id is a node in this Pattern.
Definition: pattern_inl.h:136
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Headers of a DFSCode.
Size sizeArcs() const
Returns the number of arcs in this Pattern.
Definition: pattern_inl.h:147
This contains all the information we want for a node in a DFSTree.
Definition: pattern.h:70
Size NodeId
Type for node ids.
Definition: graphElements.h:97