void floydWarshallInit(IHypergraph<Arc> const& hg, Util::Matrix<typename ArcWtFn::Weight>* pdistances, ArcWtFn arcWtFn) { typedef typename ArcWtFn::Weight Weight; Util::Matrix<Weight>& dist = *pdistances; dist.setDiagonal(Weight::one(), Weight::zero()); for (StateId tail = 0, numStates = (StateId)dist.getNumRows(); tail < numStates; ++tail) { Weight* rowTail = dist.row(tail); for (ArcId aid : hg.outArcIds(tail)) { Arc* arc = hg.outArc(tail, aid); StateId head = arc->head(); Hypergraph::plusBy(arcWtFn(arc), rowTail[head]); } } }
ArcIdIterator searchLabel(const IHypergraph<A>& hg, StateId sid, Sym label) { ArcIdRange arcIdsRange = hg.outArcIds(sid); // binary search: return boost::lower_bound(arcIdsRange, fakeArcId, CmpInputLabelWithSearchLabel<A>(hg, sid, label)); }