Return a (finite) approximation of the behavior of the automaton. In other words, compute the polynomial of the lightest accepted words (the shortlex order is used to sort words of equal weights), and their associated weight.
Arguments:
num
the number of words to find (there might be fewer, see Notes).algo
the algorithm name.The algorithm can be:
"breadth-first"
: uses the same algorithm as for the search of multiple words."yen"
: uses Yen's algorithm to retrieve multiple paths, the algorithm does not count loops as possible paths."eppstein"
: uses Eppstein's algorithm to retrieve multiple paths on any automata."auto"
: Same as "breadth-first"
for any k different from 1 (see lightest_automaton otherwise)."auto"
"a-star"
"bellman-ford"
"dijkstra"
Notes:
<+1>a + <-1>a
: it would find <-1>a
although a
is not accepted. This problem will not happen if the automaton is unambiguous, a property that can be verified using automaton.is_ambiguous.Preconditions:
See also:
import vcsn
%%automaton --strip a
context = "lal, nmin"
$ -> 0
0 -> 1 <6>a
0 -> 2 <1>a
2 -> 3 <1>b
3 -> 3 <2>b
3 -> 4 <1>c
4 -> 1 <1>d
0 -> 5 <2>a
5 -> 1 <3>b
1 -> $
a.lightest()
Note that polynomials are printed in shortlex order, i.e., an order based on the labels, although here, a weight-based order would make more sense.
a.lightest(2)
a.lightest(10)
Other algorithms can be called by specifying a second argument to the function.
Note that Yen's algorithm requires the automaton to have no cycles, as demonstrated here.
a.lightest(10, "yen")
a.lightest(10, "eppstein")