twagraph: fix highlight-edges in defrag_states
Fixes #555 reported by Dávid Smolka. * spot/twa/twagraph.cc (defrag_states): Update highlight-edge. * spot/graph/graph.hh (defrag_states): Just point to twa_graph::defrag_states in a comment, because the latter relies on the implementation detail of graph::defrag_state. * tests/python/parsetgba.py: Add test case. * NEWS: Mention the bug.
This commit is contained in:
parent
193fdd6f95
commit
55575a11e3
4 changed files with 66 additions and 0 deletions
|
|
@ -1485,6 +1485,11 @@ namespace spot
|
|||
// Shift all edges in edges_. The algorithm is
|
||||
// similar to remove_if, but it also keeps the correspondence
|
||||
// between the old and new index as newidx[old] = new.
|
||||
//
|
||||
// If you change anything to this logic, you might want to
|
||||
// double check twa_graph::defrag_states where we need to
|
||||
// predict the new edges indices in order to update
|
||||
// highlight-edges.
|
||||
unsigned tend = edges_.size();
|
||||
std::vector<edge> newidx(tend);
|
||||
unsigned dest = 1;
|
||||
|
|
|
|||
|
|
@ -1283,6 +1283,31 @@ namespace spot
|
|||
}
|
||||
std::swap(*hs, hs2);
|
||||
}
|
||||
if (auto he = get_named_prop<std::map<unsigned, unsigned>>
|
||||
("highlight-edges"))
|
||||
{
|
||||
// Unfortunately, the underlying graph, who might remove some
|
||||
// edges, know nothing about named properties. So we have to
|
||||
// predict the indices of the edges after
|
||||
// graph::defrag_states() will run. This might break if
|
||||
// graph::defrag_states() is changed.
|
||||
auto& ev = edge_vector();
|
||||
unsigned es = ev.size();
|
||||
std::vector<unsigned> newedges(es, -1U);
|
||||
unsigned edgeidx = 1;
|
||||
for (unsigned e = 1; e < es; ++e)
|
||||
{
|
||||
if (is_dead_edge(e) || newst[ev[e].dst] == -1U)
|
||||
newedges[e] = -1U;
|
||||
else
|
||||
newedges[e] = edgeidx++;
|
||||
}
|
||||
std::map<unsigned, unsigned> he2;
|
||||
for (auto [e, c]: *he)
|
||||
if (newedges[e] != -1U)
|
||||
he2.emplace(newedges[e], c);
|
||||
std::swap(*he, he2);
|
||||
}
|
||||
for (const char* prop: {"original-classes",
|
||||
"original-states",
|
||||
"degen-levels"})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue