highlight: improve support for highlighted edges
* spot/twa/twa.cc, spot/twa/twa.hh: Add a way to remove named properties. * spot/twa/twagraph.cc: Clear highlight-edges on operations that reorder the edge vector. * spot/twaalgos/randomize.cc, spot/twaalgos/randomize.hh: Preserve highlighted state, but not highlighted edges. * spot/twaalgos/hoa.cc: Adjust output of highlight-edge when the edges are not stored in order. * tests/core/readsave.test, tests/core/tgbagraph.test, tests/core/twagraph.cc: More test cases.
This commit is contained in:
parent
e17a617bc2
commit
39332fb118
9 changed files with 128 additions and 23 deletions
|
|
@ -980,14 +980,14 @@ acc-name: Buchi
|
|||
Acceptance: 1 Inf(0)
|
||||
properties: trans-labels explicit-labels state-acc deterministic
|
||||
properties: stutter-invariant terminal
|
||||
spot.highlight.edges: 1 0 2 1 3 2 4 3
|
||||
spot.highlight.edges: 3 0 1 1 4 3 2 2
|
||||
spot.highlight.states: 0 0 2 3
|
||||
--BODY--
|
||||
State: 1 /* Defined before State 0 on purpose */
|
||||
[2] 0 /* because it affects the edge numbering */
|
||||
[1&!2] 1 /* used in spot.highlight.edges */
|
||||
State: 0 {0}
|
||||
[t] 0
|
||||
State: 1
|
||||
[2] 0
|
||||
[1&!2] 1
|
||||
State: 2
|
||||
[2] 0
|
||||
[!0&1&!2] 1
|
||||
|
|
|
|||
|
|
@ -226,17 +226,34 @@ digraph G {
|
|||
node [shape="circle"]
|
||||
I [label="", style=invis, width=0]
|
||||
I -> 2
|
||||
0 [label="s1"]
|
||||
0 [label="s1", style="bold", color="#F15854"]
|
||||
1 [label="s2"]
|
||||
2 [label="s3"]
|
||||
2 [label="s3", style="bold", color="#4D4D4D"]
|
||||
}
|
||||
digraph G {
|
||||
rankdir=LR
|
||||
node [shape="circle"]
|
||||
I [label="", style=invis, width=0]
|
||||
I -> 0
|
||||
0 [label="s3"]
|
||||
0 [label="s3", style="bold", color="#4D4D4D"]
|
||||
}
|
||||
HOA: v1.1
|
||||
States: 3
|
||||
Start: 2
|
||||
AP: 0
|
||||
acc-name: all
|
||||
Acceptance: 0 t
|
||||
properties: trans-labels explicit-labels state-acc complete
|
||||
properties: deterministic
|
||||
spot.highlight.edges: 3 1 2 2 1 3
|
||||
--BODY--
|
||||
State: 0
|
||||
[t] 0
|
||||
State: 1
|
||||
[t] 0
|
||||
State: 2
|
||||
[t] 1
|
||||
--END--
|
||||
EOF
|
||||
|
||||
diff stdout expected
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <iostream>
|
||||
#include <spot/twa/twagraph.hh>
|
||||
#include <spot/twaalgos/dot.hh>
|
||||
#include <spot/twaalgos/hoa.hh>
|
||||
#include <spot/tl/defaultenv.hh>
|
||||
|
||||
static void f1()
|
||||
|
|
@ -84,7 +85,7 @@ static void f1()
|
|||
spot::print_dot(std::cout, tg);
|
||||
}
|
||||
|
||||
// Test purge with named states.
|
||||
// Test purge with named and highlighted states.
|
||||
static void f2()
|
||||
{
|
||||
auto d = spot::make_bdd_dict();
|
||||
|
|
@ -93,20 +94,44 @@ static void f2()
|
|||
auto s1 = tg->new_state();
|
||||
auto s2 = tg->new_state();
|
||||
auto s3 = tg->new_state();
|
||||
(void) s1;
|
||||
(void) s2;
|
||||
std::vector<std::string>* names;
|
||||
names = new std::vector<std::string>({"s1", "s2", "s3"});
|
||||
|
||||
tg->set_named_prop<std::vector<std::string>>("state-names", names);
|
||||
tg->set_named_prop("state-names",
|
||||
new std::vector<std::string>({"s1", "s2", "s3"}));
|
||||
{
|
||||
auto hs = new std::map<unsigned, unsigned>;
|
||||
hs->emplace(s1, 5);
|
||||
hs->emplace(s3, 7);
|
||||
tg->set_named_prop("highlight-states", hs);
|
||||
}
|
||||
tg->set_init_state(s3);
|
||||
spot::print_dot(std::cout, tg);
|
||||
tg->purge_unreachable_states();
|
||||
spot::print_dot(std::cout, tg);
|
||||
}
|
||||
|
||||
// Make sure the HOA printer adjusts the highlighted edges numbers
|
||||
static void f3()
|
||||
{
|
||||
auto d = spot::make_bdd_dict();
|
||||
auto tg = make_twa_graph(d);
|
||||
|
||||
auto hs = new std::map<unsigned, unsigned>;
|
||||
tg->set_named_prop("highlight-edges", hs);
|
||||
|
||||
auto s1 = tg->new_state();
|
||||
auto s2 = tg->new_state();
|
||||
auto s3 = tg->new_state();
|
||||
tg->set_init_state(s3);
|
||||
hs->emplace(tg->new_edge(s3, s2, bddtrue), 1);
|
||||
hs->emplace(tg->new_edge(s2, s1, bddtrue), 2);
|
||||
hs->emplace(tg->new_edge(s1, s1, bddtrue), 3);
|
||||
|
||||
spot::print_hoa(std::cout, tg, "1.1") << '\n';
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
f1();
|
||||
f2();
|
||||
f3();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue