spot  1.2.1a
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, int* livenum);
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  virtual int live_get(const fasttgba_state*)
110  {
111  assert(false);
112  return 0;
113  }
114 
115  protected:
116 
118  virtual int root (int i);
119 
120  // type def for the main structure of the Union-Find
121  typedef Sgi::hash_map<const fasttgba_state*, int,
122  fasttgba_state_ptr_hash,
123  fasttgba_state_ptr_equal> uf_map;
124 
127  uf_map el;
128 
130  std::vector<int> idneg;
131 
133  std::vector<markset *> accp;
134 
137 
140  };
141 
143  {
144  private:
145  Sgi::hash_map<const fasttgba_state*, int,
148  mutable std::vector<int> id;
149  mutable std::vector<int> rk;
150  // id of a specially managed partition of "dead" elements
151  const int DEAD;
152 
153  virtual int root(int i);
154 
155  public:
157 
158  virtual bool add(const fasttgba_state* e, int* livenum);
159 
160  virtual unsigned int size ();
161 
162  virtual unsigned int dead_size ();
163 
164  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
165 
166  virtual void make_dead(const fasttgba_state* e);
167 
168  virtual bool contains(const fasttgba_state* e);
169 
170  virtual bool same_partition(const fasttgba_state* e1,
171  const fasttgba_state* e2);
172 
173  virtual bool is_dead(const fasttgba_state* e);
174 
175  int nbPart() const;
176 
177  int maxDepth() const;
178 
179  int maxPart() const;
180 
181  void clear();
182 
183  virtual void add_acc (const fasttgba_state*, markset);
184 
185  virtual markset get_acc (const fasttgba_state*);
186 
187  virtual color get_color(const fasttgba_state*);
188 
189  virtual int max_alive();
190 
191  virtual int max_dead();
192 
193  virtual int live_get(const fasttgba_state*)
194  {
195  assert(false);
196  return 0;
197  }
198  };
199 
201  {
202  private:
203  Sgi::hash_map<const fasttgba_state*, int,
205  mutable std::vector<int> id;
206  // id of a specially managed partition of "dead" elements
207  const int DEAD;
208 
209  virtual int root(int i);
210 
211  public:
213 
214  virtual ~setOfDisjointSetsIPC_LRPC_MS();
215 
216  virtual bool add(const fasttgba_state* e, int* livenum);
217 
218  virtual unsigned int size ();
219 
220  virtual unsigned int dead_size ();
221 
222  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
223 
224  virtual void make_dead(const fasttgba_state* e);
225 
226  virtual bool contains(const fasttgba_state* e);
227 
228  virtual bool same_partition(const fasttgba_state* e1,
229  const fasttgba_state* e2);
230 
231  virtual bool is_dead(const fasttgba_state* e);
232 
233  int nbPart() const;
234 
235  int maxDepth() const;
236 
237  int maxPart() const;
238 
239  void clear();
240 
241  virtual void add_acc (const fasttgba_state*, markset);
242 
243  virtual markset get_acc (const fasttgba_state*);
244 
245  virtual color get_color(const fasttgba_state*);
246 
247  virtual int max_alive();
248 
249  virtual int max_dead();
250 
251  virtual int live_get(const fasttgba_state*)
252  {
253  assert(false);
254  return 0;
255  }
256  };
257 
274  {
275  private:
276  typedef Sgi::hash_map<const fasttgba_state*, int,
278  fasttgba_state_ptr_equal> seen_map;
279  seen_map el;
280 
281  // This stucture allows to bind a position with a state
282  struct idpair
283  {
284  int id;
285  const fasttgba_state* state;
286  };
287 
288  mutable std::vector<idpair> id;
289  // id of a specially managed partition of "dead" elements
290  const int DEAD;
291 
292  deadstore* deadstore_;
293  int realsize_;
294 
295  virtual int root(int i);
296 
297  public:
299 
301 
302  virtual bool add(const fasttgba_state* e, int* livenum);
303 
304  virtual unsigned int size ();
305 
306  virtual unsigned int dead_size ();
307 
308  virtual void unite(const fasttgba_state* e1, const fasttgba_state* e2);
309 
310  virtual void make_dead(const fasttgba_state* e);
311 
312  virtual bool contains(const fasttgba_state* e);
313 
314  virtual bool same_partition(const fasttgba_state* e1,
315  const fasttgba_state* e2);
316 
317  virtual bool is_dead(const fasttgba_state* e);
318 
319  int nbPart() const;
320 
321  int maxDepth() const;
322 
323  int maxPart() const;
324 
325  void clear();
326 
327  virtual void add_acc (const fasttgba_state*, markset);
328 
329  virtual markset get_acc (const fasttgba_state*);
330 
331  virtual color get_color(const fasttgba_state*);
332 
333  virtual int max_alive();
334 
335  virtual int max_dead();
336 
337  virtual int live_get(const fasttgba_state*);
338 
339  private:
340  unsigned int max_alive_;
341  };
342 }
343 
344 #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.
this class acts like a wrapper to the C code of the open_set.
Definition: public.hh:32
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:273
virtual bool contains(const fasttgba_state *e)
Return wether a state belong to the Union-Find structure.
Definition: union_find.hh:142
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()
virtual bool add(const fasttgba_state *e, int *livenum)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
This class act as an interface for all classes.
Definition: fasttgba_state.hh:30
acc_dict & acc_
The acceptance dictionary.
Definition: union_find.hh:136
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:130
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:127
virtual bool add(const fasttgba_state *e, int *livenum)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
virtual markset get_acc(const fasttgba_state *)
return the acceptance set of the partition containing s
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 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.
Definition: union_find.hh:200
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:139
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'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.
virtual bool add(const fasttgba_state *s, int *livenum)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
std::vector< markset * > accp
Acceptance associated to each element.
Definition: union_find.hh:133
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 add(const fasttgba_state *e, int *livenum)
Add a partition that contains only s Suppose a clone() has been done and the union-find is in charge ...
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 Fri Jun 5 2015 11:31:18 for spot by doxygen 1.8.9.1