]> granicus.if.org Git - re2c/commit
Added GTOP SSSP algorithm for computing epsilon-closure with POSIX disambiguation.
authorUlya Trofimovich <skvadrik@gmail.com>
Mon, 31 Dec 2018 12:08:42 +0000 (12:08 +0000)
committerUlya Trofimovich <skvadrik@gmail.com>
Mon, 31 Dec 2018 12:11:30 +0000 (12:11 +0000)
commit93ad7ac2450ff605f09c42bafaa23cf89b52ad8c
tree2e46035fa977010fbc8c19e54bee5ed3be07c44c
parentd3753f304a6de745cdf869df7bd5ab7f9c6e3d64
Added GTOP SSSP algorithm for computing epsilon-closure with POSIX disambiguation.

GTOP SSSP meand "Global Topsort Single Source Shortes Path".

It is well known that SSSP can be solved in linear time on DAGs (directed
acyclic graphs) by exploring graph nodes in topological order. In our case
TNFA is not a DAG (it may have cycles), but it is possible to compute fake
topologcal order by ignoring back edges.

The algorithm works by having a priority queue of nodes, where priorities
are indices of nodes in fake topological ordering. At each step, the node
with the minimal priority is popped from queue and explored. All nodes
reachable from it on admissible arcs are enqueued, unless they are already
on queue.

The resulting algorithm is of course not optimal: it can get stuck on
graphs with loops, because it will give priority to some of the loop nodes
compared to others for no good reason.

However the algorithm is simple and optimal for DAGs, therefore we keep it.
re2c/src/dfa/closure_posix.cc
re2c/src/nfa/nfa.h
re2c/src/nfa/re_to_nfa.cc