Path Results for Context-free Grammar Queries on Graphs.
Jelle Hellings · 2015
Graph query languages often use regular expressions for navigation. Traditionally, these regular expressions evaluate to binary relations on nodes, where each node pair in the resulting relation is connected by a path whose labeling is accepted by the regular expression. Recent work generalized this usage of regular expressions to context-free grammars, while keeping efficient query evaluation algorithms under the traditionalrelational semantics. We believe that the relational semantics is limiting: node relations only indicate that nodes in the graph are connected in some way, this without telling how these connections can be established and, hence, only providing limited insight in the structure of the graph. To address the limits of the relational semantics, we propose two path-based semantics for evaluating context-free grammars on graphs: evaluating context-free grammars to the set of all paths whose labeling is accepted by the context-free grammar, and to a single path whose labeling is accepted by the context-free grammar. For both path-based semantics we introduce query evaluation algorithms. The algorithm we propose for the single path semantics guarantees that this path is the shortest possible path. As this shortest path algorithm places high demands on the hardware, we also propose a less demanding approximation algorithm that only guarantees that the length of the produced path is upper bounded. All proposed algorithms have polynomial complexity in terms of the size of the context-free grammar and the graph. We show practical viability of the algorithms via performance measurements on an implementation.