dupexp: rename to copy, and preserve named states on request

* src/twaalgos/dupexp.cc, src/twaalgos/dupexp.hh: Rename to...
* src/twaalgos/copy.cc, src/twaalgos/copy.hh: ... these.
Get rid of dupexp_bfs, rename dupexp_dfs as copy, and add
an option to preserve named states.
* src/twaalgos/Makefile.am, src/tests/dupexp.test,
src/tests/ikwiad.cc, src/tests/sccsimpl.test,
src/twa/twagraph.hh, src/twaalgos/dot.cc,
src/twaalgos/stutter.cc, wrap/python/spot_impl.i: Adjust.
* NEWS: Mention this change.
This commit is contained in:
Alexandre Duret-Lutz 2015-09-30 10:59:13 +02:00
parent dcb9d7e8a8
commit 0bbcd6e85e
11 changed files with 42 additions and 54 deletions

View file

@ -34,13 +34,13 @@ twaalgos_HEADERS = \
cleanacc.hh \
complete.hh \
compsusp.hh \
copy.hh \
cycles.hh \
dtgbacomp.hh \
degen.hh \
dot.hh \
dtbasat.hh \
dtgbasat.hh \
dupexp.hh \
emptiness.hh \
emptiness_stats.hh \
gv04.hh \
@ -91,13 +91,13 @@ libtwaalgos_la_SOURCES = \
cleanacc.cc \
complete.cc \
compsusp.cc \
copy.cc \
cycles.cc \
dtgbacomp.cc \
degen.cc \
dot.cc \
dtbasat.cc \
dtgbasat.cc \
dupexp.cc \
emptiness.cc \
gv04.cc \
hoa.cc \

View file

@ -20,7 +20,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dupexp.hh"
#include "copy.hh"
#include "twa/twagraph.hh"
#include <sstream>
#include <string>
@ -32,16 +32,22 @@ namespace spot
{
namespace
{
template <class T>
class dupexp_iter: public T
class copy_iter: public tgba_reachable_iterator_depth_first
{
public:
dupexp_iter(const const_twa_ptr& a, twa::prop_set p)
: T(a), out_(make_twa_graph(a->get_dict()))
copy_iter(const const_twa_ptr& a, twa::prop_set p,
bool preserve_names)
: tgba_reachable_iterator_depth_first(a),
out_(make_twa_graph(a->get_dict()))
{
out_->copy_acceptance_of(a);
out_->copy_ap_of(a);
out_->prop_copy(a, p);
if (preserve_names)
{
names_ = new std::vector<std::string>;
out_->set_named_prop("state-names", names_);
}
}
twa_graph_ptr
@ -51,9 +57,11 @@ namespace spot
}
virtual void
process_state(const state*, int n, twa_succ_iterator*)
process_state(const state* s, int n, twa_succ_iterator*)
{
unsigned ns = out_->new_state();
if (names_)
names_->emplace_back(aut_->format_state(s));
assert(ns == static_cast<unsigned>(n) - 1);
(void)ns;
(void)n;
@ -71,22 +79,15 @@ namespace spot
protected:
twa_graph_ptr out_;
std::vector<std::string>* names_ = nullptr;
};
} // anonymous
twa_graph_ptr
tgba_dupexp_bfs(const const_twa_ptr& aut, twa::prop_set p)
copy(const const_twa_ptr& aut, twa::prop_set p, bool preserve_names)
{
dupexp_iter<tgba_reachable_iterator_breadth_first> di(aut, p);
di.run();
return di.result();
}
twa_graph_ptr
tgba_dupexp_dfs(const const_twa_ptr& aut, twa::prop_set p)
{
dupexp_iter<tgba_reachable_iterator_depth_first> di(aut, p);
copy_iter di(aut, p, preserve_names);
di.run();
return di.result();
}

View file

@ -31,12 +31,9 @@ namespace spot
{
/// \ingroup twa_misc
/// \brief Build an explicit automaton from all states of \a aut,
/// numbering states in bread first order as they are processed.
///
/// This works for using the abstract interface for automata
SPOT_API twa_graph_ptr
tgba_dupexp_bfs(const const_twa_ptr& aut, twa::prop_set p);
/// \ingroup twa_misc
/// \brief Build an explicit automaton from all states of \a aut,
/// numbering states in depth first order as they are processed.
SPOT_API twa_graph_ptr
tgba_dupexp_dfs(const const_twa_ptr& aut, twa::prop_set p);
copy(const const_twa_ptr& aut, twa::prop_set p,
bool preserve_names = false);
}

View file

@ -29,6 +29,7 @@
#include "misc/escape.hh"
#include "twa/twagraph.hh"
#include "twa/formula2bdd.hh"
#include "twaalgos/copy.hh"
#include "twaalgos/sccinfo.hh"
#include <cstdlib>
#include <cstring>
@ -534,7 +535,7 @@ namespace spot
dotty_output d(os, options);
auto aut = std::dynamic_pointer_cast<const twa_graph>(g);
if (!aut)
aut = make_twa_graph(g, twa::prop_set::all());
aut = copy(g, twa::prop_set::all(), true);
d.print(aut);
return os;
}

View file

@ -19,7 +19,6 @@
#include "stutter.hh"
#include "twa/twa.hh"
#include "dupexp.hh"
#include "misc/hash.hh"
#include "misc/hashfunc.hh"
#include "tl/apcollect.hh"