spot  2.16
cycles.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/twaalgos/sccinfo.hh>
22 #include <spot/misc/hash.hh>
23 #include <deque>
24 
25 namespace spot
26 {
63  class SPOT_API enumerate_cycles
64  {
65  protected:
68  struct state_info
69  {
71  state_info(unsigned num)
72  : seen(false), reach(false), mark(false), del(num)
73  {
74  }
75  bool seen;
76  bool reach;
77  bool mark;
78  std::vector<bool> del;
79  std::vector<unsigned> b;
80  };
81 
83  std::vector<state_info> info_;
84  const scc_info& sm_;
85 
92  struct dfs_entry
93  {
94  unsigned s;
95  unsigned succ = 0U;
96  bool f = false;
98  dfs_entry(unsigned s) noexcept
99  : s(s)
100  {
101  }
102  };
104  typedef std::vector<dfs_entry> dfs_stack;
106 
107  public:
110  virtual ~enumerate_cycles() {}
111 
117  void run(unsigned scc);
118 
119 
135  virtual bool cycle_found(unsigned start);
136 
137  private:
138  // add a new state to the dfs_ stack
139  void push_state(unsigned s);
140  // block the edge (x,y) because it cannot contribute to a new
141  // cycle currently (sub-procedure from the paper)
142  void nocycle(unsigned x, unsigned y);
143  // unmark the state y (sub-procedure from the paper)
144  void unmark(unsigned y);
145  };
146 }
Enumerate elementary cycles in a SCC.
Definition: cycles.hh:64
dfs_stack dfs_
The DFS stack.
Definition: cycles.hh:105
const_twa_graph_ptr aut_
The automaton being explored.
Definition: cycles.hh:82
virtual bool cycle_found(unsigned start)
Called whenever a cycle was found.
void run(unsigned scc)
Run in SCC scc, and call cycle_found() for any new elementary cycle found.
std::vector< dfs_entry > dfs_stack
Stack type used during DFS traversal.
Definition: cycles.hh:104
std::vector< state_info > info_
SCC information.
Definition: cycles.hh:83
const scc_info & sm_
The state map used during exploration.
Definition: cycles.hh:84
enumerate_cycles(const scc_info &map)
Construct a cycle enumerator for the given SCC.
Compute an SCC map and gather assorted information.
Definition: sccinfo.hh:465
@ U
until
std::shared_ptr< const twa_graph > const_twa_graph_ptr
Shared pointer to a const twa_graph.
Definition: fwd.hh:38
Definition: automata.hh:26
DFS stack entry for the cycle enumeration algorithm.
Definition: cycles.hh:93
dfs_entry(unsigned s) noexcept
Construct a DFS entry for state s.
Definition: cycles.hh:98
unsigned s
State index.
Definition: cycles.hh:94
Per-state information maintained by the cycle enumeration algorithm.
Definition: cycles.hh:69
std::vector< unsigned > b
BDD labeling associated with the state.
Definition: cycles.hh:79
bool reach
Whether this state is reachable from the start.
Definition: cycles.hh:76
state_info(unsigned num)
Construct with initial state number.
Definition: cycles.hh:71
std::vector< bool > del
Delayed transition set.
Definition: cycles.hh:78
bool mark
Whether this state is marked.
Definition: cycles.hh:77
bool seen
Whether this state has been visited.
Definition: cycles.hh:75

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.1