Home | History | Annotate | Download | only in lib

Lines Matching defs:arc

34 // template <class Arc>
37 // typedef typename Arc::StateId StateId;
41 // void InitVisit(const Fst<Arc> &fst);
44 // // Invoked when tree arc examined (to white/undiscovered state)
45 // bool TreeArc(StateId s, const Arc &a);
46 // // Invoked when back arc examined (to grey/unfinished state)
47 // bool BackArc(StateId s, const Arc &a);
48 // // Invoked when forward or cross arc examined (to black/finished state)
49 // bool ForwardOrCrossArc(StateId s, const Arc &a);
50 // // Invoked when state finished (PARENT is kNoStateID and ARC == NULL
52 // void FinishState(StateId s, StateId parent, const Arc *parent_arc);
63 template <class Arc>
65 typedef typename Arc::StateId StateId;
67 DfsState(const Fst<Arc> &fst, StateId s): state_id(s), arc_iter(fst, s) {}
70 ArcIterator< Fst<Arc> > arc_iter; // and its corresponding arcs
76 template <class Arc, class V, class ArcFilter>
77 void DfsVisit(const Fst<Arc> &fst, V *visitor, ArcFilter filter) {
78 typedef typename Arc::StateId StateId;
89 stack<DfsState<Arc> *> state_stack; // DFS execution stack
102 state_stack.push(new DfsState<Arc>(fst, root));
105 DfsState<Arc> *dfs_state = state_stack.top();
107 ArcIterator< Fst<Arc> > &aiter = dfs_state->arc_iter;
113 DfsState<Arc> *parent_state = state_stack.top();
115 ArcIterator< Fst<Arc> > &piter = parent_state->arc_iter;
123 const Arc &arc = aiter.Value();
124 if (!filter(arc)) {
128 int next_color = state_color[arc.nextstate];
132 dfs = visitor->TreeArc(s, arc);
134 state_color[arc.nextstate] = kDfsGrey;
135 state_stack.push(new DfsState<Arc>(fst, arc.nextstate));
136 dfs = visitor->InitState(arc.nextstate, root);
139 dfs = visitor->BackArc(s, arc);
143 dfs = visitor->ForwardOrCrossArc(s, arc);
157 template <class Arc, class V>
158 void DfsVisit(const Fst<Arc> &fst, V *visitor) {
159 DfsVisit(fst, visitor, AnyArcFilter<Arc>());