graph: rename num_transitions() as num_edges()

And in fact, rename most "trans*" as "edges*", because that what they
really are.

* src/bin/autfilt.cc, src/bin/ltlcross.cc, src/bin/randaut.cc,
src/dstarparse/dra2ba.cc, src/dstarparse/dstarparse.yy,
src/dstarparse/nra2nba.cc, src/dstarparse/nsa2tgba.cc,
src/graph/graph.hh, src/graph/ngraph.hh, src/ltlvisit/exclusive.cc,
src/parseaut/parseaut.yy, src/tests/complementation.cc,
src/tests/graph.cc, src/tests/ltl2tgba.cc, src/tests/ngraph.cc,
src/tests/twagraph.cc, src/twa/twagraph.cc, src/twa/twagraph.hh,
src/twa/twamask.hh, src/twaalgos/are_isomorphic.cc,
src/twaalgos/are_isomorphic.hh, src/twaalgos/canonicalize.cc,
src/twaalgos/cleanacc.cc, src/twaalgos/complete.cc,
src/twaalgos/compsusp.cc, src/twaalgos/cycles.cc,
src/twaalgos/degen.cc, src/twaalgos/dot.cc, src/twaalgos/dtbasat.cc,
src/twaalgos/dtgbacomp.cc, src/twaalgos/dtgbasat.cc,
src/twaalgos/dupexp.cc, src/twaalgos/emptiness.cc,
src/twaalgos/isunamb.cc, src/twaalgos/isweakscc.cc,
src/twaalgos/ltl2tgba_fm.cc, src/twaalgos/mask.hh,
src/twaalgos/minimize.cc, src/twaalgos/postproc.cc,
src/twaalgos/powerset.cc, src/twaalgos/product.cc,
src/twaalgos/randomgraph.cc, src/twaalgos/randomize.cc,
src/twaalgos/randomize.hh, src/twaalgos/relabel.cc,
src/twaalgos/remfin.cc, src/twaalgos/safety.cc, src/twaalgos/sbacc.cc,
src/twaalgos/sccfilter.cc, src/twaalgos/sepsets.cc,
src/twaalgos/simulation.cc, src/twaalgos/stutter.cc,
src/twaalgos/totgba.cc: Rename these.
This commit is contained in:
Alexandre Duret-Lutz 2015-06-11 23:52:02 +02:00
parent a1ba0a89c5
commit af8634d8c4
53 changed files with 685 additions and 693 deletions

View file

@ -53,31 +53,31 @@ namespace spot
delete namer;
}
void twa_graph::merge_transitions()
void twa_graph::merge_edges()
{
g_.remove_dead_transitions_();
g_.remove_dead_edges_();
typedef graph_t::trans_storage_t tr_t;
g_.sort_transitions_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.acc < rhs.acc;
// Do not sort on conditions, we'll merge
// them.
});
typedef graph_t::edge_storage_t tr_t;
g_.sort_edges_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.acc < rhs.acc;
// Do not sort on conditions, we'll merge
// them.
});
auto& trans = this->transition_vector();
auto& trans = this->edge_vector();
unsigned tend = trans.size();
unsigned out = 0;
unsigned in = 1;
// Skip any leading false transition.
// Skip any leading false edge.
while (in < tend && trans[in].cond == bddfalse)
++in;
if (in < tend)
@ -87,11 +87,11 @@ namespace spot
trans[out] = trans[in];
for (++in; in < tend; ++in)
{
if (trans[in].cond == bddfalse) // Unusable transition
if (trans[in].cond == bddfalse) // Unusable edge
continue;
// Merge transitions with the same source, destination, and
// Merge edges with the same source, destination, and
// acceptance. (We test the source last, because this is the
// most likely test to be true as transitions are ordered by
// most likely test to be true as edges are ordered by
// sources and then destinations.)
if (trans[out].dst == trans[in].dst
&& trans[out].acc == trans[in].acc
@ -113,31 +113,31 @@ namespace spot
tend = out;
out = in = 2;
// FIXME: We could should also merge transitions when using
// FIXME: We could should also merge edges when using
// fin_acceptance, but the rule for Fin sets are different than
// those for Inf sets, (and we need to be careful if a set is used
// both as Inf and Fin)
if ((in < tend) && !acc().uses_fin_acceptance())
{
typedef graph_t::trans_storage_t tr_t;
g_.sort_transitions_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.cond.id() < rhs.cond.id();
// Do not sort on acceptance, we'll merge
// them.
});
typedef graph_t::edge_storage_t tr_t;
g_.sort_edges_([](const tr_t& lhs, const tr_t& rhs)
{
if (lhs.src < rhs.src)
return true;
if (lhs.src > rhs.src)
return false;
if (lhs.dst < rhs.dst)
return true;
if (lhs.dst > rhs.dst)
return false;
return lhs.cond.id() < rhs.cond.id();
// Do not sort on acceptance, we'll merge
// them.
});
for (; in < tend; ++in)
{
// Merge transitions with the same source, destination,
// Merge edges with the same source, destination,
// and conditions. (We test the source last, for the
// same reason as above.)
if (trans[out].dst == trans[in].dst
@ -157,7 +157,7 @@ namespace spot
trans.resize(out);
}
g_.chain_transitions_();
g_.chain_edges_();
}
void twa_graph::purge_unreachable_states()
@ -228,7 +228,7 @@ namespace spot
order.push_back(src);
continue;
}
auto& t = g_.trans_storage(tid);
auto& t = g_.edge_storage(tid);
todo.back().second = t.next_succ;
unsigned dst = t.dst;
if (useful[dst] != 1)
@ -246,13 +246,13 @@ namespace spot
bool useless = true;
while (t)
{
// Erase any transition to a useless state.
// Erase any edge to a useless state.
if (!useful[t->dst])
{
t.erase();
continue;
}
// if we have a transition to a useful state, then the
// if we have a edge to a useful state, then the
// state is useful.
useless = false;
++t;

View file

@ -73,22 +73,22 @@ namespace spot
}
};
struct SPOT_API twa_graph_trans_data
struct SPOT_API twa_graph_edge_data
{
bdd cond;
acc_cond::mark_t acc;
explicit twa_graph_trans_data()
explicit twa_graph_edge_data()
: cond(bddfalse), acc(0)
{
}
twa_graph_trans_data(bdd cond, acc_cond::mark_t acc = 0U)
twa_graph_edge_data(bdd cond, acc_cond::mark_t acc = 0U)
: cond(cond), acc(acc)
{
}
bool operator<(const twa_graph_trans_data& other) const
bool operator<(const twa_graph_edge_data& other) const
{
if (cond.id() < other.cond.id())
return true;
@ -97,7 +97,7 @@ namespace spot
return acc < other.acc;
}
bool operator==(const twa_graph_trans_data& other) const
bool operator==(const twa_graph_edge_data& other) const
{
return cond.id() == other.cond.id() &&
acc == other.acc;
@ -110,19 +110,19 @@ namespace spot
public twa_succ_iterator
{
private:
typedef typename Graph::transition transition;
typedef typename Graph::edge edge;
typedef typename Graph::state_data_t state;
const Graph* g_;
transition t_;
transition p_;
edge t_;
edge p_;
public:
twa_graph_succ_iterator(const Graph* g, transition t)
twa_graph_succ_iterator(const Graph* g, edge t)
: g_(g), t_(t)
{
}
virtual void recycle(transition t)
virtual void recycle(edge t)
{
t_ = t;
}
@ -135,7 +135,7 @@ namespace spot
virtual bool next()
{
p_ = g_->trans_storage(p_).next_succ;
p_ = g_->edge_storage(p_).next_succ;
return p_;
}
@ -148,22 +148,22 @@ namespace spot
{
assert(!done());
return const_cast<twa_graph_state*>
(&g_->state_data(g_->trans_storage(p_).dst));
(&g_->state_data(g_->edge_storage(p_).dst));
}
virtual bdd current_condition() const
{
assert(!done());
return g_->trans_data(p_).cond;
return g_->edge_data(p_).cond;
}
virtual acc_cond::mark_t current_acceptance_conditions() const
{
assert(!done());
return g_->trans_data(p_).acc;
return g_->edge_data(p_).acc;
}
transition pos() const
edge pos() const
{
return p_;
}
@ -173,8 +173,8 @@ namespace spot
class SPOT_API twa_graph final: public twa
{
public:
typedef digraph<twa_graph_state, twa_graph_trans_data> graph_t;
typedef graph_t::trans_storage_t trans_storage_t;
typedef digraph<twa_graph_state, twa_graph_edge_data> graph_t;
typedef graph_t::edge_storage_t edge_storage_t;
protected:
graph_t g_;
@ -248,9 +248,9 @@ namespace spot
return g_.num_states();
}
unsigned num_transitions() const
unsigned num_edges() const
{
return g_.num_transitions();
return g_.num_edges();
}
void set_init_state(graph_t::state s)
@ -323,49 +323,49 @@ namespace spot
return format_state(state_number(st));
}
twa_graph_trans_data& trans_data(const twa_succ_iterator* it)
twa_graph_edge_data& edge_data(const twa_succ_iterator* it)
{
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
return g_.trans_data(i->pos());
return g_.edge_data(i->pos());
}
twa_graph_trans_data& trans_data(unsigned t)
twa_graph_edge_data& edge_data(unsigned t)
{
return g_.trans_data(t);
return g_.edge_data(t);
}
const twa_graph_trans_data& trans_data(const twa_succ_iterator* it) const
const twa_graph_edge_data& edge_data(const twa_succ_iterator* it) const
{
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
return g_.trans_data(i->pos());
return g_.edge_data(i->pos());
}
const twa_graph_trans_data& trans_data(unsigned t) const
const twa_graph_edge_data& edge_data(unsigned t) const
{
return g_.trans_data(t);
return g_.edge_data(t);
}
trans_storage_t& trans_storage(const twa_succ_iterator* it)
edge_storage_t& edge_storage(const twa_succ_iterator* it)
{
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
return g_.trans_storage(i->pos());
return g_.edge_storage(i->pos());
}
trans_storage_t& trans_storage(unsigned t)
edge_storage_t& edge_storage(unsigned t)
{
return g_.trans_storage(t);
return g_.edge_storage(t);
}
const trans_storage_t
trans_storage(const twa_succ_iterator* it) const
const edge_storage_t
edge_storage(const twa_succ_iterator* it) const
{
auto* i = down_cast<const twa_graph_succ_iterator<graph_t>*>(it);
return g_.trans_storage(i->pos());
return g_.edge_storage(i->pos());
}
const trans_storage_t trans_storage(unsigned t) const
const edge_storage_t edge_storage(unsigned t) const
{
return g_.trans_storage(t);
return g_.edge_storage(t);
}
unsigned new_state()
@ -378,19 +378,19 @@ namespace spot
return g_.new_states(n);
}
unsigned new_transition(unsigned src, unsigned dst,
unsigned new_edge(unsigned src, unsigned dst,
bdd cond, acc_cond::mark_t acc = 0U)
{
return g_.new_transition(src, dst, cond, acc);
return g_.new_edge(src, dst, cond, acc);
}
unsigned new_acc_transition(unsigned src, unsigned dst,
unsigned new_acc_edge(unsigned src, unsigned dst,
bdd cond, bool acc = true)
{
if (acc)
return g_.new_transition(src, dst, cond, acc_.all_sets());
return g_.new_edge(src, dst, cond, acc_.all_sets());
else
return g_.new_transition(src, dst, cond);
return g_.new_edge(src, dst, cond);
}
#ifndef SWIG
@ -404,18 +404,18 @@ namespace spot
auto states()
SPOT_RETURN(g_.states());
auto transitions() const
SPOT_RETURN(g_.transitions());
auto transitions()
SPOT_RETURN(g_.transitions());
auto edges() const
SPOT_RETURN(g_.edges());
auto edges()
SPOT_RETURN(g_.edges());
auto transition_vector() const
SPOT_RETURN(g_.transition_vector());
auto transition_vector()
SPOT_RETURN(g_.transition_vector());
auto edge_vector() const
SPOT_RETURN(g_.edge_vector());
auto edge_vector()
SPOT_RETURN(g_.edge_vector());
auto is_dead_transition(const graph_t::trans_storage_t& t) const
SPOT_RETURN(g_.is_dead_transition(t));
auto is_dead_edge(const graph_t::edge_storage_t& t) const
SPOT_RETURN(g_.is_dead_edge(t));
#endif
virtual bdd compute_support_conditions(const state* s) const
@ -426,9 +426,9 @@ namespace spot
return sum;
}
/// Iterate over all transitions, and merge those with compatible
/// Iterate over all edges, and merge those with compatible
/// extremities and acceptance.
void merge_transitions();
void merge_edges();
/// Remove all states without successors.
void purge_dead_states();
@ -440,7 +440,7 @@ namespace spot
{
assert(has_state_based_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first transition, since the remaining should be
// Stop at the first edge, since the remaining should be
// labeled identically.
return t.acc;
return 0U;
@ -450,7 +450,7 @@ namespace spot
{
assert(has_state_based_acc() || num_sets() == 0);
for (auto& t: g_.out(s))
// Stop at the first transition, since the remaining should be
// Stop at the first edge, since the remaining should be
// labeled identically.
return acc_.accepting(t.acc);
return false;
@ -464,11 +464,11 @@ namespace spot
bool operator==(const twa_graph& aut) const
{
if (num_states() != aut.num_states() ||
num_transitions() != aut.num_transitions() ||
num_edges() != aut.num_edges() ||
num_sets() != aut.num_sets())
return false;
auto& trans1 = transition_vector();
auto& trans2 = aut.transition_vector();
auto& trans1 = edge_vector();
auto& trans2 = aut.edge_vector();
return std::equal(trans1.begin() + 1, trans1.end(),
trans2.begin() + 1);
}

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement
// Copyright (C) 2013, 2014, 2015 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -33,8 +33,8 @@ namespace spot
/// can optionally be reset to \a init.
SPOT_API const_twa_ptr
build_twa_mask_keep(const const_twa_ptr& to_mask,
const state_set& to_keep,
const state* init = 0);
const state_set& to_keep,
const state* init = 0);
/// \ingroup twa_on_the_fly_algorithms
/// \brief Mask a TGBA, rejecting a given set of states.
@ -44,8 +44,8 @@ namespace spot
/// \a init.
SPOT_API const_twa_ptr
build_twa_mask_ignore(const const_twa_ptr& to_mask,
const state_set& to_ignore,
const state* init = 0);
const state_set& to_ignore,
const state* init = 0);
/// \ingroup twa_on_the_fly_algorithms
@ -61,6 +61,6 @@ namespace spot
/// all_acceptance_conditions().
SPOT_API const_twa_ptr
build_twa_mask_acc_ignore(const const_twa_ptr& to_mask,
unsigned to_ignore,
const state* init = 0);
unsigned to_ignore,
const state* init = 0);
}