spot 2.16
reachiter.hh
1// -*- coding: utf-8 -*-
2// Copyright (C) by the Spot authors, see the AUTHORS file for details.
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#pragma once
20
21#include <spot/misc/hash.hh>
22#include <spot/twa/twa.hh>
23#include <stack>
24#include <deque>
25
26namespace spot
27{
31 {
32 public:
36
42 virtual void run();
43
51 virtual void add_state(const state* s) = 0;
53 virtual const state* next_state() = 0;
55
58 virtual bool want_state(const state* s) const;
59
61 virtual void start();
63 virtual void end();
64
70 virtual void process_state(const state* s, int n, twa_succ_iterator* si);
83 virtual void process_link(const state* in_s, int in,
84 const state* out_s, int out,
85 const twa_succ_iterator* si);
86
87 protected:
89
91 };
92
98 {
99 public:
102
103 virtual void add_state(const state* s) override;
104 virtual const state* next_state() override;
105
106 protected:
107 std::deque<const state*> todo;
108 };
109
113 {
114 public:
118
124 virtual void run();
125
128 virtual bool want_state(const state* s) const;
129
131 virtual void start();
133 virtual void end();
134
140 virtual void process_state(const state* s, int n, twa_succ_iterator* si);
153 virtual void process_link(const state* in_s, int in,
154 const state* out_s, int out,
155 const twa_succ_iterator* si);
156
157 protected:
159
164 {
165 const state* src;
166 int src_n;
168 };
169 std::deque<stack_item> todo;
170
172 virtual void push(const state* s, int sn);
174 virtual void pop();
175 };
176
184 {
185 public:
192 bool on_stack(int sn) const;
193 protected:
194 virtual void push(const state* s, int sn) override;
195 virtual void pop() override;
196
197 std::unordered_set<int> stack_;
198 };
199}
Abstract class for states.
Definition: twa.hh:49
An implementation of spot::twa_reachable_iterator that browses states breadth first.
Definition: reachiter.hh:98
virtual void add_state(const state *s) override
Called by run() to obtain the next state to process.
twa_reachable_iterator_breadth_first(const const_twa_ptr &a)
Construct a breadth-first iterator.
virtual const state * next_state() override
Called by run() to obtain the next state to process.
std::deque< const state * > todo
A queue of states yet to explore.
Definition: reachiter.hh:107
Iterate over all states of an automaton using a DFS.
Definition: reachiter.hh:184
std::unordered_set< int > stack_
DFS stack of pending states.
Definition: reachiter.hh:197
virtual void pop() override
Pop the DFS stack.
bool on_stack(int sn) const
Whether state sn is on the DFS stack.
twa_reachable_iterator_depth_first_stack(const const_twa_ptr &a)
Construct a depth-first iterator that exposes its stack.
virtual void push(const state *s, int sn) override
Push a new state in todo.
Iterate over all states of an automaton using a DFS.
Definition: reachiter.hh:113
virtual void push(const state *s, int sn)
Push a new state in todo.
virtual void pop()
Pop the DFS stack.
virtual void run()
Iterate over all reachable states of a spot::tgba.
virtual void process_state(const state *s, int n, twa_succ_iterator *si)
virtual bool want_state(const state *s) const
virtual void process_link(const state *in_s, int in, const state *out_s, int out, const twa_succ_iterator *si)
twa_reachable_iterator_depth_first(const const_twa_ptr &a)
Construct a depth-first iterator.
virtual void end()
Called by run() once all states have been explored.
const_twa_ptr aut_
The spot::tgba to explore.
Definition: reachiter.hh:158
state_map< int > seen
Definition: reachiter.hh:160
std::deque< stack_item > todo
the DFS stack
Definition: reachiter.hh:169
virtual void start()
Called by run() before starting its iteration.
Iterate over all reachable states of a spot::tgba.
Definition: reachiter.hh:31
state_map< int > seen
States already seen.
Definition: reachiter.hh:90
virtual void process_state(const state *s, int n, twa_succ_iterator *si)
virtual void process_link(const state *in_s, int in, const state *out_s, int out, const twa_succ_iterator *si)
virtual void add_state(const state *s)=0
Called by run() to obtain the next state to process.
virtual void end()
Called by run() once all states have been explored.
virtual void run()
Iterate over all reachable states of a spot::tgba.
virtual void start()
Called by run() before starting its iteration.
virtual bool want_state(const state *s) const
twa_reachable_iterator(const const_twa_ptr &a)
Construct an iterator over reachable states.
const_twa_ptr aut_
The spot::tgba to explore.
Definition: reachiter.hh:88
virtual const state * next_state()=0
Called by run() to obtain the next state to process.
Iterate over the successors of a state.
Definition: twa.hh:425
std::shared_ptr< const twa > const_twa_ptr
Shared pointer to a const twa.
Definition: fwd.hh:36
Definition: automata.hh:26
std::unordered_map< const state *, val, state_ptr_hash, state_ptr_equal > state_map
Unordered map of abstract states.
Definition: twa.hh:204
DFS stack entry holding a state, its DFS number, and its active successor iterator.
Definition: reachiter.hh:164
const state * src
Source state (as a const_state*).
Definition: reachiter.hh:165
twa_succ_iterator * it
Iterator over successors of src.
Definition: reachiter.hh:167
int src_n
Source state index.
Definition: reachiter.hh:166

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Feb 27 2015 10:00:07 for spot by doxygen 1.9.4