dot: use circles if state names are all short
* spot/twaalgos/dot.cc: Check for state names sizes. * tests/core/readsave.test: Test the change. * tests/core/tgbagraph.test: Adjust.
This commit is contained in:
parent
b11c07b351
commit
eb0a0b6b34
3 changed files with 34 additions and 2 deletions
|
|
@ -33,6 +33,7 @@
|
|||
#include <spot/twaalgos/sccinfo.hh>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
|
|
@ -541,10 +542,19 @@ namespace spot
|
|||
if (opt_shape_ == ShapeAuto)
|
||||
{
|
||||
if (sn_ || sprod_ || aut->num_states() > 100)
|
||||
{
|
||||
opt_shape_ = ShapeEllipse;
|
||||
else
|
||||
// If all state names are short, prefer circles.
|
||||
if (sn_ && std::all_of(sn_->begin(), sn_->end(),
|
||||
[](const std::string& s)
|
||||
{ return s.size() <= 2; }))
|
||||
opt_shape_ = ShapeCircle;
|
||||
}
|
||||
else
|
||||
{
|
||||
opt_shape_ = ShapeCircle;
|
||||
}
|
||||
}
|
||||
auto si =
|
||||
std::unique_ptr<scc_info>(opt_scc_ ? new scc_info(aut) : nullptr);
|
||||
|
||||
|
|
|
|||
|
|
@ -538,6 +538,26 @@ EOF
|
|||
autfilt --dot=bao1 in | grep -v '>' >out
|
||||
diff out expected2
|
||||
|
||||
cat >expected3 <<EOF
|
||||
digraph G {
|
||||
rankdir=LR
|
||||
node [shape="circle"]
|
||||
I [label="", style=invis, width=0]
|
||||
0 [label="6", peripheries=2]
|
||||
u0 [label="...", shape=none, width=0, height=0]
|
||||
1 [label="0", peripheries=2]
|
||||
2 [label="1", peripheries=2]
|
||||
3 [label="2", peripheries=2]
|
||||
4 [label="3", peripheries=2]
|
||||
u4 [label="...", shape=none, width=0, height=0]
|
||||
}
|
||||
EOF
|
||||
|
||||
# States should be circled even if <5 causes all states to be named,
|
||||
# because the names are smaller then 2 characters anyway.
|
||||
ltl2tgba --det 'Ga | Gb | Gc' -d'<5' | grep -v '>' >out
|
||||
diff out expected3
|
||||
|
||||
# Let's pretend that this is some used supplied input, as discussed in
|
||||
# the comments of https://github.com/adl/hoaf/issues/39
|
||||
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ digraph G {
|
|||
}
|
||||
digraph G {
|
||||
rankdir=LR
|
||||
node [shape="circle"]
|
||||
I [label="", style=invis, width=0]
|
||||
I -> 2
|
||||
0 [label="s1"]
|
||||
|
|
@ -231,6 +232,7 @@ digraph G {
|
|||
}
|
||||
digraph G {
|
||||
rankdir=LR
|
||||
node [shape="circle"]
|
||||
I [label="", style=invis, width=0]
|
||||
I -> 0
|
||||
0 [label="s3"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue