spot  1.99.7
reachiter.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2009, 2011, 2013 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 <spot/misc/hash.hh>
26 #include <spot/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);
156  virtual void process_link(const state* in_s, int in,
157  const state* out_s, int out,
158  const twa_succ_iterator* si);
159 
160  protected:
161  const_twa_ptr aut_;
162 
163  typedef std::unordered_map<const state*, int,
164  state_ptr_hash, state_ptr_equal> seen_map;
165  seen_map seen;
166  struct stack_item
167  {
168  const state* src;
169  int src_n;
170  twa_succ_iterator* it;
171  };
172  std::deque<stack_item> todo;
173 
175  virtual void push(const state* s, int sn);
177  virtual void pop();
178  };
179 
187  {
188  public:
189  tgba_reachable_iterator_depth_first_stack(const const_twa_ptr& a);
194  bool on_stack(int sn) const;
195  protected:
196  virtual void push(const state* s, int sn);
197  virtual void pop();
198 
199  std::unordered_set<int> stack_;
200  };
201 }
Definition: graph.hh:32
virtual void pop()
Pop the DFS stack.
const_twa_ptr aut_
The spot::tgba to explore.
Definition: reachiter.hh:161
An Equivalence Relation for state*.
Definition: twa.hh:141
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:43
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:165
Iterate over all reachable states of a spot::tgba.
Definition: reachiter.hh:34
Iterate over the successors of a state.
Definition: twa.hh:332
An implementation of spot::tgba_reachable_iterator that browses states breadth first.
Definition: reachiter.hh:101
Hash Function for state*.
Definition: twa.hh:165
Iterate over all states of an automaton using a DFS.
Definition: reachiter.hh:185
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:172
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 Fri Jan 15 2016 13:01:50 for spot by doxygen 1.8.9.1