The exact path length problem is to determine if there is a path of a given fixed cost between two vertices. This paper focuses on the exact path problem for costs −1, 0 or +1 between all pairs of vertices in an edge-weighted digraph. The edge weights are from {−1, +1}. In this case, this paper gives an O(n ω ) exact path solution.Here ω is the best exponent for matrix multiplication and O is the asymptotic upper-bound mod polylog factors.Variations of this algorithm determine which pairs of digraph nodes have Dyck or semi-Dyck labeled paths between them, assuming two parenthesis. Therefore, determining digraph reachability for Dyck or semi-Dyck labeled paths costs O(n ω ). A path label is made by concatenating all symbols along the path's edges.The exact path length problem has many applications. These applications include the labeled path problems given here, which in turn, also have numerous applications. * This current paper uses standard definitions of Dyck and semi-Dyck languages.Context-free language constrained graph problems are fundamental to a plethora of challenges. This paper gives algorithms for determining Dyck (semi-Dyck) constrained paths on digraphs based on the exact path problem. Dyck and semi-Dyck contextfree languages are important. A central application for the exact path problem is for determining Dyck and semi-Dyck constrained paths in digraphs. Here these languages have a single parenthesis type.Definition 1 (Exact path length problem [2]) Consider an integer edge weighted digraph G. Given an integer κ, the EPL (exact path length problem) is to determine whether there is a path between a given pair vertices costing exactly κ.
Nykänen and Ukkonen [2]show the general EPL is N P-Complete. They also give a pseudo-polynomial algorithm for the EPL. The current paper uses a special case of the EPL where κ ∈ {−1, 0, +1} and edge costs are from the set {−1, +1}.Given these restricted edge costs, and for κ = 0, applying Nykänen and Ukkonen's algorithm costs O(n 3 + n ω log |κ|) time 1 , see [2]. For κ = 0, their algorithm costs O(n 3 ).Solving this Dyck (semi-Dyck) labeled path problem is interesting due to the close relationship between transitive closure, Boolean and algebraic matrix multiplication, and context-free grammar recognition. For example, Lee [3] gives an equivalence between Context-free parsers and Boolean matrix multiplication algorithms.
Semi-Dyck and Dyck Constrained GraphsDyck and semi-Dyck languages are parenthesis languages. Dyck or semi-Dyck languages with two parenthesis symbols and n total parentheses can be parsed in O(n) time and space. However, efficiently computing Dyck (and semi-Dyck) constrained reachability on digraphs seems more challenging.Let D be a Dyck language of one open-parentheses symbol a and one closeparentheses symbol a −1 . A sentence w ∈ D iff w can be reduced using right-inverse reduction, e.g. a a −1 = , to the empty string . The Dyck language D is derivable from the grammar:Semi-Dyck languages allow reductions using both right-inverses and left-invers...