Commit 31bf8c2c authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

ngraph: support aliasing states

* src/graph/ngraph.hh (alias_state): New method.
* src/graphtest/ngraph.cc: Use it.
parent 424de903
...@@ -77,6 +77,13 @@ namespace spot ...@@ -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() ...@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment