aGrUM  0.16.0
pattern.h
Go to the documentation of this file.
1 
30 #ifndef GUM_PATTERN_H
31 #define GUM_PATTERN_H
32 
33 #include <agrum/agrum.h>
34 
35 #include <agrum/graphs/diGraph.h>
36 
39 
40 namespace gum {
41  namespace prm {
42  namespace gspan {
43 
44  class NeighborIterator;
45 
73  class Pattern : private DiGraph {
74  public:
75  // =========================================================================
77  // ==========================================================================
79 
81  Pattern();
82 
84  Pattern(const Pattern& source);
85 
87  ~Pattern();
88 
90  // =========================================================================
92  // ==========================================================================
94 
100 
102  LabelData& label(NodeId node);
103 
105  const LabelData& label(NodeId node) const;
106 
108  LabelData& label(NodeId i, NodeId j);
109 
111  const LabelData& label(NodeId i, NodeId j) const;
112 
114  LabelData& label(const Arc& arc);
115 
117  const LabelData& label(const Arc& arc) const;
118 
119  // Returns the last added LabelData.
120  LabelData& lastAdded();
121 
122  // Returns the last added LabelData.
123  const LabelData& lastAdded() const;
124 
138  void addArc(NodeId i, NodeId j, LabelData& l);
139 
141  bool exists(NodeId id) const;
142 
144  bool exists(NodeId tail, NodeId head) const;
145 
147  Size size() const;
148 
150  Size sizeArcs() const;
151 
154  void rightmostPath(std::list< NodeId >& r_path) const;
155 
157  std::string toDot(size_t name) const;
158 
160  // =========================================================================
162  // ==========================================================================
164  const NodeGraphPart& nodes() const;
165 
166  const ArcSet& arcs() const;
167 
169  // =========================================================================
171  // ==========================================================================
173 
175  DFSCode& code();
176 
178  const DFSCode& code() const;
179 
181  EdgeCode& edgeCode(NodeId tail, NodeId head);
182 
184  EdgeCode& edgeCode(const Arc& arc);
185 
187  const EdgeCode& edgeCode(NodeId tail, NodeId head) const;
188 
190  const EdgeCode& edgeCode(const Arc& arc) const;
191 
193  void pop_back();
194 
197  void remove(NodeId node);
198 
199  bool isMinimal();
200 
202 
203  private:
206 
210 
214 
217 
229 
236  bool __rec(Pattern& p,
237  Bijection< NodeId, NodeId >& node_map,
238  NodeId u,
239  NodeId v);
240 
242  bool __not_rec(Pattern& p,
243  Bijection< NodeId, NodeId >& node_map,
244  NodeId u,
245  NodeId v);
246 
247  // to avoid clang++ warnings
248  using DiGraph::addNode;
249  using DiGraph::addArc;
250  using DiGraph::toDot;
251  using DiGraph::parents;
252  using DiGraph::children;
253  };
254  } /* namespace gspan */
255  } /* namespace prm */
256 } /* namespace gum */
257 #ifndef GUM_NO_INLINE
259 #endif // GUM_NO_INLINE
260 
261 #endif /* GUM_PATTERN_H */
EdgeCode & edgeCode(NodeId tail, NodeId head)
Returns the EdgeCode of an edge of this Pattern.
Definition: pattern_inl.h:179
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:35
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Inner class to handle data about labels in this interface graph.
Pattern()
Default constructor.
Definition: pattern_inl.h:35
ArcProperty< std::pair< LabelData *, EdgeCode *> > __arc_map
Mapping between edges in this Pattern and their respective LabelData.
Definition: pattern.h:213
DFSCode & code()
Returns the DFSCode of this Pattern.
Definition: pattern_inl.h:173
NodeId addNodeWithLabel(LabelData &l)
Insert a node with the given LabelData.
Definition: pattern_inl.h:41
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:99
Reprensent a Depth First Search coding of a graph.
Definition: DFSCode.h:53
bool isMinimal()
Returns the DFSCode of this Pattern.
Definition: pattern.cpp:56
~Pattern()
Destructor.
Definition: pattern_inl.h:38
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
virtual NodeId addNode()
insert a new node and return its id
The class for generic Hash Tables.
Definition: hashTable.h:679
LabelData & label(NodeId node)
Returns the LabelData assigned to node.
Definition: pattern_inl.h:50
represent a DFS code used by gspan.
Definition: edgeCode.h:52
Size size() const
Returns the number of nodes in this Pattern.
Definition: pattern_inl.h:147
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:111
NodeProperty< LabelData *> __node_map
Mapping between nodes in this Pattern and their respective LabelData.
Definition: pattern.h:209
virtual const std::string toDot() const
to friendly display the content of the graph in the DOT syntax
Definition: diGraph.cpp:68
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
bool __not_rec(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
A non recursive bugged version of __rec.
Definition: pattern.cpp:189
Class for node sets in graph.
LabelData & lastAdded()
Insert a node with the given LabelData.
Definition: pattern_inl.h:68
const NodeGraphPart & nodes() const
Definition: pattern_inl.h:166
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:153
LabelData * __last
The last LabelData added to this pattern.
Definition: pattern.h:216
const ArcSet & arcs() const
Definition: pattern_inl.h:170
bool __rec(Pattern &p, Bijection< NodeId, NodeId > &node_map, NodeId u, NodeId v)
Recurisve method used by __expandCodeIsMinimal.
Definition: pattern.cpp:128
void pop_back()
Remove the last EdgeCode of this pattern.
Definition: pattern_inl.h:207
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:205
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void addArc(NodeId i, NodeId j, LabelData &l)
Add an arc to this Pattern.
Definition: pattern_inl.h:118
bool exists(NodeId id) const
Returns true if id is a node in this Pattern.
Definition: pattern_inl.h:139
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size sizeArcs() const
Returns the number of arcs in this Pattern.
Definition: pattern_inl.h:150
This contains all the information we want for a node in a DFSTree.
Definition: pattern.h:73
Size NodeId
Type for node ids.
Definition: graphElements.h:98