FST  openfst-1.6.1
OpenFst Library
shortest-path.cc
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 
4 #include <fst/script/fst-class.h>
7 
8 namespace fst {
9 namespace script {
10 
11 // 1
12 void ShortestPath(const FstClass &ifst, MutableFstClass *ofst,
13  std::vector<WeightClass> *distance,
14  const ShortestPathOptions &opts) {
15  if (!ArcTypesMatch(ifst, *ofst, "ShortestPath")) {
16  ofst->SetProperties(kError, kError);
17  return;
18  }
19  ShortestPathArgs1 args(ifst, ofst, distance, opts);
20  Apply<Operation<ShortestPathArgs1>>("ShortestPath", ifst.ArcType(), &args);
21 }
22 
23 // 2
24 void ShortestPath(const FstClass &ifst, MutableFstClass *ofst, int32 n,
25  bool unique, bool first_path,
26  const WeightClass &weight_threshold, int64 state_threshold) {
27  if (!ArcTypesMatch(ifst, *ofst, "ShortestPath")) {
28  ofst->SetProperties(kError, kError);
29  return;
30  }
31  ShortestPathArgs2 args(ifst, ofst, n, unique, first_path, weight_threshold,
32  state_threshold);
33  Apply<Operation<ShortestPathArgs2>>("ShortestPath", ifst.ArcType(), &args);
34 }
35 
39 
43 
44 } // namespace script
45 } // namespace fst
const string & ArcType() const override
Definition: fst-class.h:289
REGISTER_FST_OPERATION(Compress, StdArc, CompressArgs)
int64_t int64
Definition: types.h:27
int32_t int32
Definition: types.h:26
constexpr uint64 kError
Definition: properties.h:33
bool ArcTypesMatch(const M &m, const N &n, const string &op_name)
Definition: script-impl.h:177
void SetProperties(uint64 props, uint64 mask)
Definition: fst-class.h:455
void ShortestPath(ShortestPathArgs1 *args)
Definition: shortest-path.h:41