ngraph: support aliasing states
* src/graph/ngraph.hh (alias_state): New method. * src/graphtest/ngraph.cc: Use it.
This commit is contained in:
parent
424de90385
commit
31bf8c2c1e
2 changed files with 11 additions and 2 deletions
|
|
@ -77,6 +77,13 @@ namespace spot
|
||||||
return p.first->second;
|
return p.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Give an alternate name to a state.
|
||||||
|
/// \return true iff the newname was already used.
|
||||||
|
bool alias_state(state s, name newname)
|
||||||
|
{
|
||||||
|
return !name_to_state.insert(std::make_pair(newname, s)).second;
|
||||||
|
}
|
||||||
|
|
||||||
state get_state(name n) const
|
state get_state(name n) const
|
||||||
{
|
{
|
||||||
return name_to_state.at(n);
|
return name_to_state.at(n);
|
||||||
|
|
|
||||||
|
|
@ -389,10 +389,12 @@ bool f9()
|
||||||
spot::named_graph<graph_t, std::string> gg(g);
|
spot::named_graph<graph_t, std::string> gg(g);
|
||||||
auto s1 = gg.new_state("s1");
|
auto s1 = gg.new_state("s1");
|
||||||
gg.new_state("s2");
|
gg.new_state("s2");
|
||||||
gg.new_state("s3");
|
auto s3 = gg.new_state("s3");
|
||||||
|
gg.alias_state(s3, "s3b");
|
||||||
|
|
||||||
gg.new_transition("s1", "s2", 1, 3);
|
gg.new_transition("s1", "s2", 1, 3);
|
||||||
gg.new_transition("s1", "s3", 2, 5);
|
gg.new_transition("s1", "s3", 2, 5);
|
||||||
gg.new_transition("s2", "s3", 3, 7);
|
gg.new_transition("s2", "s3b", 3, 7);
|
||||||
gg.new_transition("s3", "s2", 4, 9);
|
gg.new_transition("s3", "s2", 4, 9);
|
||||||
|
|
||||||
dot(std::cout, gg);
|
dot(std::cout, gg);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue