Difference: ShortestPathDoc (10 vs. 11)

Revision 112018-04-27 - MichaelRiley

Line: 1 to 1
META TOPICPARENT name="FstQuickTour"



This operation produces an FST containing the n -shortest paths in the input FST. The n -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 -shortest with n > 1 (valid for TropicalWeight).



template<class Arc>
void ShortestPath(const Fst<Arc> &ifst, MutableFst<Arc> *ofst, size_t n = 1);
| %DOX{namespacefst.html#ShortestPath[doc]}% |
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 A:


2-shortest paths in A:




  • 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)
where V = # of states and E = # of arcs. See here for more discussion on efficiency.


See here for a discussion on efficient usage.

See Also

ShortestDistance, State Queues


-- CyrilAllauzen - 05 Jul 2007

META FILEATTACHMENT attr="" autoattached="1" comment="2-shortest path example" date="1184014286" name="shortestpath3.jpg" path="shortestpath3.jpg" size="18910" user="Main.CyrilAllauzen" version="1"
META FILEATTACHMENT attr="" autoattached="1" comment="shortest path input example" date="1184014217" name="shortestpath1.jpg" path="shortestpath1.jpg" size="9583" user="Main.CyrilAllauzen" version="1"
META FILEATTACHMENT attr="" autoattached="1" comment="1-shortest path example" date="1184014250" name="shortestpath2.jpg" path="shortestpath2.jpg" size="6231" user="Main.CyrilAllauzen" version="1"
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback