This operation produces an FST containing the n
-shortest paths in the input FST.
-shortest paths are the n
-lowest weight paths w.r.t. the natural semiring order.
The single path that can be read from the ith of at most n
transitions leaving the initial state of the resulting FST is the ith shortest path.
The weights need to be right distributive and have the path
property. They also need to be left distributive as well for n
> 1 (valid for
void ShortestPath(const Fst<Arc> &ifst, MutableFst<Arc> *ofst, size_t n = 1);
fstshortestpath [--opts] a.fst out.fst
--nshortest: type = int64, default = 1
Return N-shortest paths
--unique: default = false
Return only distinct strings (NB: must be acceptor; epsilons treated as regular symbols)
Shortest path in
2-shortest paths in
- 1-shortest path:
- Time: O(V log V + E)
- Space: O(V)
- n-shortest paths:
- Time: O(V log V + n V + n E)
- Space: O(n V)
= # of states and E
= # of arcs. See here
for more discussion on efficiency.
for a discussion on efficient usage.
- 05 Jul 2007