spot  1.99.4a
reachiter.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2009, 2011, 2013, 2015 Laboratoire de Recherche et
3 // Développement de l'Epita (LRDE).
4 // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6
5 // (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
6 // Pierre et Marie Curie.
7 //
8 // This file is part of Spot, a model checking library.
9 //
10 // Spot is free software; you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation; either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Spot is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 // License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 #pragma once
24 
25 #include "misc/hash.hh"
26 #include "twa/twa.hh"
27 #include <stack>
28 #include <deque>
29 
30 namespace spot
31 {
34  class SPOT_API tgba_reachable_iterator
35  {
36  public:
37  tgba_reachable_iterator(const const_twa_ptr& a);
38  virtual ~tgba_reachable_iterator();
39 
45  virtual void run();
46 
54  virtual void add_state(const state* s) = 0;
56  virtual const state* next_state() = 0;
58 
61  virtual bool want_state(const state* s) const;
62 
64  virtual void start();
66  virtual void end();
67 
73  virtual void process_state(const state* s, int n, twa_succ_iterator* si);
86  virtual void process_link(const state* in_s, int in,
87  const state* out_s, int out,
88  const twa_succ_iterator* si);
89 
90  protected:
91  const_twa_ptr aut_;
92 
93  typedef std::unordered_map<const state*, int,
95  seen_map seen;
96  };
97 
103  {
104  public:
105  tgba_reachable_iterator_breadth_first(const const_twa_ptr& a);
106 
107  virtual void add_state(const state* s);
108  virtual const state* next_state();
109 
110  protected:
111  std::deque<const state*> todo;
112  };
113 
117  {
118  public:
119  tgba_reachable_iterator_depth_first(const const_twa_ptr& a);
121 
127  virtual void run();
128 
131  virtual bool want_state(const state* s) const;
132 
134  virtual void start();
136  virtual void end();
137 
143  virtual void process_state(const state* s, int n, twa_succ_iterator* si);
144 
155  virtual bool will_pop_state(const state* s, int n, twa_succ_iterator* si);
156 
169  virtual void process_link(const state* in_s, int in,
170  const state* out_s, int out,
171  const twa_succ_iterator* si);
172 
173  protected:
174  const_twa_ptr aut_;
175 
176  typedef std::unordered_map<const state*, int,
177  state_ptr_hash, state_ptr_equal> seen_map;
178  seen_map seen;
179  struct stack_item
180  {
181  const state* src;
182  int src_n;
183  twa_succ_iterator* it;
184  };
185  std::deque<stack_item> todo;
186 
188  virtual void push(const state* s, int sn);
190  virtual void pop();
191  };
192 
200  {
201  public:
202  tgba_reachable_iterator_depth_first_stack(const const_twa_ptr& a);
207  bool on_stack(int sn) const;
208  protected:
209  virtual void push(const state* s, int sn);
210  virtual void pop();
211 
212  std::unordered_set<int> stack_;
213  };
214 }
Definition: graph.hh:32
virtual void pop()
Pop the DFS stack.
const_twa_ptr aut_
The spot::tgba to explore.
Definition: reachiter.hh:174
An Equivalence Relation for state*.
Definition: twa.hh:140
bool on_stack(int sn) const
Whether state sn is on the DFS stack.
const_twa_ptr aut_
The spot::tgba to explore.
Definition: reachiter.hh:91
Abstract class for states.
Definition: twa.hh:42
virtual void push(const state *s, int sn)
Push a new state in todo.
seen_map seen
States already seen.
Definition: reachiter.hh:95
seen_map seen
States already seen.
Definition: reachiter.hh:178
Iterate over all reachable states of a spot::tgba.
Definition: reachiter.hh:34
Iterate over the successors of a state.
Definition: twa.hh:331
An implementation of spot::tgba_reachable_iterator that browses states breadth first.
Definition: reachiter.hh:101
Hash Function for state*.
Definition: twa.hh:164
Iterate over all states of an automaton using a DFS.
Definition: reachiter.hh:198
Iterate over all states of an automaton using a DFS.
Definition: reachiter.hh:116
std::deque< stack_item > todo
the DFS stack
Definition: reachiter.hh:185
std::deque< const state * > todo
A queue of states yet to explore.
Definition: reachiter.hh:111

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sun Oct 11 2015 10:50:08 for spot by doxygen 1.8.9.1