Commit 6b516df3 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

dot: display pairs of states for products

* src/twaalgos/dot.cc: Here.
* wrap/python/tests/automata.ipynb: Test it.
* NEWS: Document this.
parent e3b8ed7b
......@@ -48,6 +48,11 @@ New in spot 1.99.5a (not yet released)
automata already tagged as "deterministic", and "inherently-weak"
or "weak" even for automata tagged "weak" or "terminal".
* The dot output will display pair of states when displaying an
automaton built as an explicit product. This works in IPython
with spot.product() or spot.product_or() and in the shell with
autfilt's --product or --product-or options.
* Renamings:
is_guarantee_automaton() -> is_terminal_automaton()
tgba_run -> twa_run
......
......@@ -56,6 +56,7 @@ namespace spot
bool opt_html_labels_ = false;
const_twa_graph_ptr aut_;
std::vector<std::string>* sn_ = nullptr;
std::vector<std::pair<unsigned, unsigned>>* sprod_ = nullptr;
std::string* name_ = nullptr;
acc_cond::mark_t inf_sets_ = 0U;
acc_cond::mark_t fin_sets_ = 0U;
......@@ -385,6 +386,8 @@ namespace spot
os_ << '"';
if (has_name)
escape_str(os_, (*sn_)[s]);
else if (sprod_)
os_ << (*sprod_)[s].first << ',' << (*sprod_)[s].second;
else
os_ << s;
if (acc)
......@@ -399,6 +402,8 @@ namespace spot
os_ << '<';
if (has_name)
escape_html(os_, (*sn_)[s]);
else if (sprod_)
os_ << (*sprod_)[s].first << ',' << (*sprod_)[s].second;
else
os_ << s;
if (acc)
......@@ -416,6 +421,8 @@ namespace spot
os_ << " " << s << " [label=\"";
if (sn_ && s < sn_->size() && !(*sn_)[s].empty())
escape_str(os_, (*sn_)[s]);
else if (sprod_)
os_ << (*sprod_)[s].first << ',' << (*sprod_)[s].second;
else
os_ << s;
os_ << '"';
......@@ -466,13 +473,24 @@ namespace spot
{
aut_ = aut;
if (opt_want_state_names_)
sn_ = aut->get_named_prop<std::vector<std::string>>("state-names");
{
sn_ = aut->get_named_prop<std::vector<std::string>>("state-names");
// We have no names. Do we have product sources?
if (!sn_)
{
sprod_ = aut->get_named_prop
<std::vector<std::pair<unsigned, unsigned>>>
("product-states");
if (sprod_ && aut->num_states() != sprod_->size())
sprod_ = nullptr;
}
}
if (opt_name_)
name_ = aut_->get_named_prop<std::string>("automaton-name");
mark_states_ = !opt_force_acc_trans_ && aut_->prop_state_acc();
if (opt_shape_ == ShapeAuto)
{
if (sn_ || aut->num_states() > 100)
if (sn_ || sprod_ || aut->num_states() > 100)
opt_shape_ = ShapeEllipse;
else
opt_shape_ = ShapeCircle;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment