Return a (finite) approximation of the behavior of the automaton. In other words, compute the polynomial of the lightest accepted words (according to the shortlex order), 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 bin
context = "lal_char, 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 -> $
bin.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.
bin.lightest(2)
bin.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.
bin.lightest(10, "yen")
bin.lightest(10, "eppstein")