dot: add an option to display the acceptance
* src/tgbaalgos/dotty.cc: Display the acceptance if "a" is used. * src/bin/common_aoutput.cc, src/bin/dstar2tgba.cc, src/tgbaalgos/dotty.hh: Document it. * src/tgbatest/readsave.test: Test it.
This commit is contained in:
parent
095ac93b5b
commit
5b3034b605
5 changed files with 68 additions and 16 deletions
|
|
@ -50,10 +50,10 @@ static const argp_option options[] =
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
{ 0, 0, 0, 0, "Output format:", 3 },
|
{ 0, 0, 0, 0, "Output format:", 3 },
|
||||||
{ "dot", OPT_DOT, "c|h|n|N|s|t|v", OPTION_ARG_OPTIONAL,
|
{ "dot", OPT_DOT, "c|h|n|N|s|t|v", OPTION_ARG_OPTIONAL,
|
||||||
"GraphViz's format (default). Add letters to chose (c) circular nodes, "
|
"GraphViz's format (default). Add letters for "
|
||||||
"(h) horizontal layout, (v) vertical layout, (n) with name, "
|
"(a) acceptance display, (c) circular nodes, (h) horizontal layout, "
|
||||||
"(N) without name, (s) with SCCs, "
|
"(v) vertical layout, (n) with name, (N) without name, (s) with SCCs, "
|
||||||
"(t) always transition-based acceptance.", 0 },
|
"(t) force transition-based acceptance.", 0 },
|
||||||
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
||||||
"Output the automaton in HOA format. Add letters to select "
|
"Output the automaton in HOA format. Add letters to select "
|
||||||
"(s) state-based acceptance, (t) transition-based acceptance, "
|
"(s) state-based acceptance, (t) transition-based acceptance, "
|
||||||
|
|
|
||||||
|
|
@ -72,10 +72,10 @@ static const argp_option options[] =
|
||||||
/**************************************************/
|
/**************************************************/
|
||||||
{ 0, 0, 0, 0, "Output format:", 3 },
|
{ 0, 0, 0, 0, "Output format:", 3 },
|
||||||
{ "dot", OPT_DOT, "c|h|n|N|s|t|v", OPTION_ARG_OPTIONAL,
|
{ "dot", OPT_DOT, "c|h|n|N|s|t|v", OPTION_ARG_OPTIONAL,
|
||||||
"GraphViz's format (default). Add letters to chose (c) circular nodes, "
|
"GraphViz's format (default). Add letters for (a) acceptance display, "
|
||||||
"(h) horizontal layout, (v) vertical layout, (n) with name, "
|
"(c) circular nodes, (h) horizontal layout, (v) vertical layout, "
|
||||||
"(N) without name, (s) with SCCs, "
|
"(n) with name, (N) without name, (s) with SCCs, "
|
||||||
"(t) always transition-based acceptance.", 0 },
|
"(t) force transition-based acceptance.", 0 },
|
||||||
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
{ "hoaf", 'H', "s|t|m|l", OPTION_ARG_OPTIONAL,
|
||||||
"Output the automaton in HOA format. Add letters to select "
|
"Output the automaton in HOA format. Add letters to select "
|
||||||
"(s) state-based acceptance, (t) transition-based acceptance, "
|
"(s) state-based acceptance, (t) transition-based acceptance, "
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,12 @@ namespace spot
|
||||||
bool opt_horizontal_ = true;
|
bool opt_horizontal_ = true;
|
||||||
bool opt_name_ = false;
|
bool opt_name_ = false;
|
||||||
bool opt_circles_ = false;
|
bool opt_circles_ = false;
|
||||||
|
bool opt_show_acc_ = false;
|
||||||
bool mark_states_ = false;
|
bool mark_states_ = false;
|
||||||
bool opt_scc_ = false;
|
bool opt_scc_ = false;
|
||||||
const_tgba_digraph_ptr aut_;
|
const_tgba_digraph_ptr aut_;
|
||||||
std::vector<std::string>* sn_;
|
std::vector<std::string>* sn_;
|
||||||
|
std::string* name_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dotty_output(std::ostream& os, const char* options)
|
dotty_output(std::ostream& os, const char* options)
|
||||||
|
|
@ -55,6 +57,9 @@ namespace spot
|
||||||
while (char c = *options++)
|
while (char c = *options++)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'a':
|
||||||
|
opt_show_acc_ = true;
|
||||||
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
opt_circles_ = true;
|
opt_circles_ = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -88,9 +93,19 @@ namespace spot
|
||||||
os_ << "digraph G {\n";
|
os_ << "digraph G {\n";
|
||||||
if (opt_horizontal_)
|
if (opt_horizontal_)
|
||||||
os_ << " rankdir=LR\n";
|
os_ << " rankdir=LR\n";
|
||||||
if (opt_name_)
|
if (name_ || opt_show_acc_)
|
||||||
if (auto n = aut_->get_named_prop<std::string>("automaton-name"))
|
{
|
||||||
escape_str(os_ << " label=\"", *n) << "\"\n labelloc=\"t\"\n";
|
os_ << " label=\"";
|
||||||
|
if (name_)
|
||||||
|
{
|
||||||
|
escape_str(os_, *name_);
|
||||||
|
if (opt_show_acc_)
|
||||||
|
os_ << "\\n";
|
||||||
|
}
|
||||||
|
if (opt_show_acc_)
|
||||||
|
os_ << aut_->get_acceptance();
|
||||||
|
os_ << "\"\n labelloc=\"t\"\n";
|
||||||
|
}
|
||||||
if (opt_circles_)
|
if (opt_circles_)
|
||||||
os_ << " node [shape=\"circle\"]\n";
|
os_ << " node [shape=\"circle\"]\n";
|
||||||
os_ << " I [label=\"\", style=invis, ";
|
os_ << " I [label=\"\", style=invis, ";
|
||||||
|
|
@ -137,6 +152,8 @@ namespace spot
|
||||||
{
|
{
|
||||||
aut_ = aut;
|
aut_ = aut;
|
||||||
sn_ = aut->get_named_prop<std::vector<std::string>>("state-names");
|
sn_ = aut->get_named_prop<std::vector<std::string>>("state-names");
|
||||||
|
if (opt_name_)
|
||||||
|
name_ = aut_->get_named_prop<std::string>("automaton-name");
|
||||||
mark_states_ = !opt_force_acc_trans_ && aut_->is_sba();
|
mark_states_ = !opt_force_acc_trans_ && aut_->is_sba();
|
||||||
auto si =
|
auto si =
|
||||||
std::unique_ptr<scc_info>(opt_scc_ ? new scc_info(aut) : nullptr);
|
std::unique_ptr<scc_info>(opt_scc_ ? new scc_info(aut) : nullptr);
|
||||||
|
|
@ -147,7 +164,7 @@ namespace spot
|
||||||
for (unsigned i = 0; i < sccs; ++i)
|
for (unsigned i = 0; i < sccs; ++i)
|
||||||
{
|
{
|
||||||
os_ << " subgraph cluster_" << i << " {\n";
|
os_ << " subgraph cluster_" << i << " {\n";
|
||||||
if (opt_name_)
|
if (name_ || opt_show_acc_)
|
||||||
// Reset the label, otherwise the graph label would
|
// Reset the label, otherwise the graph label would
|
||||||
// be inherited by the cluster.
|
// be inherited by the cluster.
|
||||||
os_ << " label=\"\"\n";
|
os_ << " label=\"\"\n";
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ namespace spot
|
||||||
/// different option. Presently the following options are
|
/// different option. Presently the following options are
|
||||||
/// supported: 'v' for vertical output, 'h' for horizontal output,
|
/// supported: 'v' for vertical output, 'h' for horizontal output,
|
||||||
/// 't' force transition-based acceptance, 'N' hide the name of the
|
/// 't' force transition-based acceptance, 'N' hide the name of the
|
||||||
/// automaton, 'n' shows the name, 'c' uses circle-shaped states.
|
/// automaton, 'n' shows the name, 'c' uses circle-shaped states,
|
||||||
|
/// 'a' shows the acceptance.
|
||||||
SPOT_API std::ostream&
|
SPOT_API std::ostream&
|
||||||
dotty_reachable(std::ostream& os,
|
dotty_reachable(std::ostream& os,
|
||||||
const const_tgba_ptr& g,
|
const const_tgba_ptr& g,
|
||||||
|
|
|
||||||
|
|
@ -314,15 +314,12 @@ digraph G {
|
||||||
I [label="", style=invis, height=0]
|
I [label="", style=invis, height=0]
|
||||||
I -> 3
|
I -> 3
|
||||||
subgraph cluster_0 {
|
subgraph cluster_0 {
|
||||||
label=""
|
|
||||||
1 [label="s1", peripheries=2]
|
1 [label="s1", peripheries=2]
|
||||||
}
|
}
|
||||||
subgraph cluster_1 {
|
subgraph cluster_1 {
|
||||||
label=""
|
|
||||||
0 [label="s0", peripheries=2]
|
0 [label="s0", peripheries=2]
|
||||||
}
|
}
|
||||||
subgraph cluster_2 {
|
subgraph cluster_2 {
|
||||||
label=""
|
|
||||||
3 [label="s3"]
|
3 [label="s3"]
|
||||||
}
|
}
|
||||||
0 -> 0 [label="b"]
|
0 -> 0 [label="b"]
|
||||||
|
|
@ -337,3 +334,40 @@ EOF
|
||||||
diff output expected
|
diff output expected
|
||||||
|
|
||||||
test 1 = `$autfilt -H input --complete | $autfilt --is-complete --count`
|
test 1 = `$autfilt -H input --complete | $autfilt --is-complete --count`
|
||||||
|
|
||||||
|
|
||||||
|
$ltl2tgba --dot=a 'GFa & GFb' >output
|
||||||
|
cat output
|
||||||
|
cat >expected <<EOF
|
||||||
|
digraph G {
|
||||||
|
rankdir=LR
|
||||||
|
label="Inf(0)&Inf(1)"
|
||||||
|
labelloc="t"
|
||||||
|
I [label="", style=invis, width=0]
|
||||||
|
I -> 0
|
||||||
|
0 [label="0"]
|
||||||
|
0 -> 0 [label="a & b\n{0,1}"]
|
||||||
|
0 -> 0 [label="!a & !b"]
|
||||||
|
0 -> 0 [label="!a & b\n{1}"]
|
||||||
|
0 -> 0 [label="a & !b\n{0}"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
diff output expected
|
||||||
|
|
||||||
|
$ltl2tgba --dot=an 'GFa & GFb' >output
|
||||||
|
cat output
|
||||||
|
cat >expected <<EOF
|
||||||
|
digraph G {
|
||||||
|
rankdir=LR
|
||||||
|
label="G(Fa & Fb)\\nInf(0)&Inf(1)"
|
||||||
|
labelloc="t"
|
||||||
|
I [label="", style=invis, width=0]
|
||||||
|
I -> 0
|
||||||
|
0 [label="0"]
|
||||||
|
0 -> 0 [label="a & b\n{0,1}"]
|
||||||
|
0 -> 0 [label="!a & !b"]
|
||||||
|
0 -> 0 [label="!a & b\n{1}"]
|
||||||
|
0 -> 0 [label="a & !b\n{0}"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
diff output expected
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue