spot  1.2.1a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
union_find.hh
1 // Copyright (C) 2012 Laboratoire de Recherche et Développement
2 // de l'Epita (LRDE).
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SPOT_FASTTGBAALGOS_EC_UNION_FIND_HH
20 # define SPOT_FASTTGBAALGOS_EC_UNION_FIND_HH
21 
22 #include "misc/hash.hh"
23 #include "fasttgba/fasttgba.hh"
24 #include "boost/tuple/tuple.hpp"
25 
26 
27 #include <cassert>
28 #include <iosfwd>
29 #include <functional>
30 #include <memory>
31 #include <unordered_map>
32 #include <vector>
33 #include "deadstore.hh"
34 
35 namespace spot
36 {
46  class union_find
47  {
48  public:
49 
52  union_find (acc_dict& acc);
53 
55  virtual ~union_find ();
56 
60  virtual bool add (const fasttgba_state* s);
61 
65  virtual void unite (const fasttgba_state* left,
66  const fasttgba_state* right);
67 
70  virtual bool same_partition (const fasttgba_state* left,
71  const fasttgba_state* right);
72 
75  virtual void add_acc (const fasttgba_state* s, markset m);
76 
79  virtual markset get_acc (const fasttgba_state* s);
80 
82  virtual bool contains (const fasttgba_state* s);
83 
85  virtual void make_dead (const fasttgba_state* s);
86 
89  virtual bool is_dead (const fasttgba_state* s);
90 
92  enum color {Alive, Dead, Unknown};
93 
94  virtual color get_color(const fasttgba_state*);
95 
98  virtual int max_alive();
99 
102  virtual int max_dead();
103 
105  virtual unsigned int size ();
106 
107  virtual unsigned int dead_size ();
108 
109  protected:
110 
112  virtual int root (int i);
113 
114  // type def for the main structure of the Union-Find
115  typedef Sgi::hash_map<const fasttgba_state*, int,
117  fasttgba_state_ptr_equal> uf_map;
118 
121  uf_map el;
122 
124  std::vector<int> idneg;
125 
127  std::vector<markset *> accp;
128 
131 
134  };
135 
137  {
138  private:
139  Sgi::hash_map<const fasttgba_state*, int,
142  mutable std::vector<int> id;
143  mutable std::vector<int> rk;
144  // id of a specially managed partition of "dead" elements
145  const int DEAD = 0;
146 
147  virtual int root(int i);
148 
149  public:
151 
152  virtual bool add(const fasttgba_state* e);
153 
154  virtual unsigned int size ();
155 
156  virtual unsigned int dead_size ();
157 
158  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
159 
160  virtual void make_dead(const fasttgba_state* e);
161 
162  virtual bool contains(const fasttgba_state* e);
163 
164  virtual bool same_partition(const fasttgba_state* e1,
165  const fasttgba_state* e2);
166 
167  virtual bool is_dead(const fasttgba_state* e);
168 
169  int nbPart() const;
170 
171  int maxDepth() const;
172 
173  int maxPart() const;
174 
175  void clear();
176 
177  virtual void add_acc (const fasttgba_state*, markset);
178 
179  virtual markset get_acc (const fasttgba_state*);
180 
181  virtual color get_color(const fasttgba_state*);
182 
183  virtual int max_alive();
184 
185  virtual int max_dead();
186  };
187 
189  {
190  private:
191  Sgi::hash_map<const fasttgba_state*, int,
193  mutable std::vector<int> id;
194  // id of a specially managed partition of "dead" elements
195  const int DEAD = 0;
196 
197  virtual int root(int i);
198 
199  public:
201 
202  virtual ~setOfDisjointSetsIPC_LRPC_MS();
203 
204  virtual bool add(const fasttgba_state* e);
205 
206  virtual unsigned int size ();
207 
208  virtual unsigned int dead_size ();
209 
210  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
211 
212  virtual void make_dead(const fasttgba_state* e);
213 
214  virtual bool contains(const fasttgba_state* e);
215 
216  virtual bool same_partition(const fasttgba_state* e1,
217  const fasttgba_state* e2);
218 
219  virtual bool is_dead(const fasttgba_state* e);
220 
221  int nbPart() const;
222 
223  int maxDepth() const;
224 
225  int maxPart() const;
226 
227  void clear();
228 
229  virtual void add_acc (const fasttgba_state*, markset);
230 
231  virtual markset get_acc (const fasttgba_state*);
232 
233  virtual color get_color(const fasttgba_state*);
234 
235  virtual int max_alive();
236 
237  virtual int max_dead();
238  };
239 
256  {
257  private:
258  typedef Sgi::hash_map<const fasttgba_state*, int,
260  fasttgba_state_ptr_equal> seen_map;
261  seen_map el;
262 
263  // This stucture allows to bind a position with a state
264  struct idpair
265  {
266  int id;
267  const fasttgba_state* state;
268  };
269 
270  mutable std::vector<idpair> id;
271  // id of a specially managed partition of "dead" elements
272  const int DEAD = 0;
273 
274  deadstore* deadstore_;
275  int realsize_;
276 
277  virtual int root(int i);
278 
279  public:
281 
283 
284  virtual bool add(const fasttgba_state* e);
285 
286  virtual unsigned int size ();
287 
288  virtual unsigned int dead_size ();
289 
290  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
291 
292  virtual void make_dead(const fasttgba_state* e);
293 
294  virtual bool contains(const fasttgba_state* e);
295 
296  virtual bool same_partition(const fasttgba_state* e1,
297  const fasttgba_state* e2);
298 
299  virtual bool is_dead(const fasttgba_state* e);
300 
301  int nbPart() const;
302 
303  int maxDepth() const;
304 
305  int maxPart() const;
306 
307  void clear();
308 
309  virtual void add_acc (const fasttgba_state*, markset);
310 
311  virtual markset get_acc (const fasttgba_state*);
312 
313  virtual color get_color(const fasttgba_state*);
314 
315  virtual int max_alive();
316 
317  virtual int max_dead();
318 
319  private:
320  unsigned int max_alive_;
321  };
322 }
323 
324 #endif // SPOT_FASTTGBAALGOS_EC_UNION_FIND_HH
virtual bool is_dead(const fasttgba_state *e)
check wether the root of the set containing this scc is dead.
virtual unsigned int size()
The current size of the union find.
virtual markset get_acc(const fasttgba_state *)
return the acceptance set of the partition containing s
this class propose an union find based on a deadstore. The idea is to used a dedicated map for the st...
Definition: union_find.hh:255
virtual bool contains(const fasttgba_state *e)
Return wether a state belong to the Union-Find structure.
virtual bool add(const fasttgba_state *e)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
Definition: union_find.hh:136
virtual bool contains(const fasttgba_state *e)
Return wether a state belong to the Union-Find structure.
virtual unsigned int size()
The current size of the union find.
virtual int max_alive()
This class act as an interface for all classes.
Definition: fasttgba_state.hh:30
acc_dict & acc_
The acceptance dictionary.
Definition: union_find.hh:130
virtual void add_acc(const fasttgba_state *, markset)
Add the acceptance set to the partition that contains the state s.
virtual void make_dead(const fasttgba_state *s)
perform a union with dead
std::vector< int > idneg
For each element store the id of the parent.
Definition: union_find.hh:124
Abstract class for states.
Definition: state.hh:40
virtual void unite(const fasttgba_state *e1, const fasttgba_state *e2)
Perform the union of the two partition containing left and right. No assumptions over the resulting p...
uf_map el
the structure used to the storage An element is associated to an integer
Definition: union_find.hh:121
virtual markset get_acc(const fasttgba_state *)
return the acceptance set of the partition containing s
virtual bool add(const fasttgba_state *e)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
virtual void add_acc(const fasttgba_state *, markset)
Add the acceptance set to the partition that contains the state s.
color
The color for a new State.
Definition: union_find.hh:92
virtual bool add(const fasttgba_state *e)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
virtual unsigned int size()
The current size of the union find.
virtual void make_dead(const fasttgba_state *e)
perform a union with dead
virtual void unite(const fasttgba_state *e1, const fasttgba_state *e2)
Perform the union of the two partition containing left and right. No assumptions over the resulting p...
virtual int root(int i)
grab the id of the root associated to an element.
virtual ~union_find()
A simple destructor.
virtual bool add(const fasttgba_state *s)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
Definition: union_find.hh:188
virtual bool same_partition(const fasttgba_state *e1, const fasttgba_state *e2)
Return true if the partition of left is the same that the partition of right.
union_find(acc_dict &acc)
The constructor for the Union-Find structure acc the acceptance dictionary.
virtual int max_dead()
virtual void make_dead(const fasttgba_state *e)
perform a union with dead
virtual void add_acc(const fasttgba_state *, markset)
Add the acceptance set to the partition that contains the state s.
virtual bool contains(const fasttgba_state *e)
Return wether a state belong to the Union-Find structure.
virtual unsigned int size()
The current size of the union find.
Definition: fasttgba_state.hh:76
markset empty
Avoid to re-create some elements.
Definition: union_find.hh:133
virtual bool same_partition(const fasttgba_state *e1, const fasttgba_state *e2)
Return true if the partition of left is the same that the partition of right.
virtual markset get_acc(const fasttgba_state *)
return the acceptance set of the partition containing s
virtual bool same_partition(const fasttgba_state *left, const fasttgba_state *right)
Return true if the partition of left is the same that the partition of right.
virtual markset get_acc(const fasttgba_state *s)
return the acceptance set of the partition containing s
virtual bool is_dead(const fasttgba_state *e)
check wether the root of the set containing this scc is dead.
This class represents a set of acceptance marks.
Definition: markset.hh:35
This class represent a dead store. For now it&#39;s just a set but it can be combined with bitstate hasin...
Definition: deadstore.hh:41
virtual bool contains(const fasttgba_state *s)
Return wether a state belong to the Union-Find structure.
Definition: acc_dict.hh:31
Definition: fasttgba_state.hh:88
virtual void add_acc(const fasttgba_state *s, markset m)
Add the acceptance set to the partition that contains the state s.
Definition: union_find.hh:46
virtual void make_dead(const fasttgba_state *e)
perform a union with dead
virtual bool same_partition(const fasttgba_state *e1, const fasttgba_state *e2)
Return true if the partition of left is the same that the partition of right.
virtual bool is_dead(const fasttgba_state *e)
check wether the root of the set containing this scc is dead.
std::vector< markset * > accp
Acceptance associated to each element.
Definition: union_find.hh:127
virtual void unite(const fasttgba_state *left, const fasttgba_state *right)
Perform the union of the two partition containing left and right. No assumptions over the resulting p...
virtual bool is_dead(const fasttgba_state *s)
check wether the root of the set containing this scc is dead.
virtual void unite(const fasttgba_state *e1, const fasttgba_state *e2)
Perform the union of the two partition containing left and right. No assumptions over the resulting p...

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Tue Jan 21 2014 16:52:01 for spot by doxygen 1.8.5