10 static const size_t INFINITY = std::numeric_limits<size_t>::max();
13 static bool loopback(
size_t node,
size_t narcs,
const size_t *arcs)
15 for (
size_t i = 0; i < narcs; ++i)
51 std::stack<size_t> &stack,
52 std::vector<size_t> &lowlink,
53 std::vector<bool> &trivial,
56 const size_t link = stack.size();
60 const size_t *arcs = dfa.
states[i]->arcs;
61 for (
size_t c = 0; c < dfa.
nchars; ++c)
63 const size_t j = arcs[c];
66 if (lowlink[j] == UNDEFINED)
68 scc(dfa, stack, lowlink, trivial, j);
70 if (lowlink[j] < lowlink[i])
72 lowlink[i] = lowlink[j];
77 if (lowlink[i] == link)
82 trivial[i] = i == stack.top()
98 const std::vector<bool> &trivial,
99 std::vector<size_t> &fill,
102 if (fill[i] == UNDEFINED)
105 const size_t *arcs = dfa.
states[i]->arcs;
106 for (
size_t c = 0; c < dfa.
nchars; ++c)
108 const size_t j = arcs[c];
128 const size_t size = dfa.
states.size();
131 std::stack<size_t> stack;
132 std::vector<size_t> lowlink(size, UNDEFINED);
133 std::vector<bool> trivial(size,
false);
134 scc(dfa, stack, lowlink, trivial, 0);
138 fill.resize(size, UNDEFINED);
145 for (
size_t i = 1; i < size; ++i)
static void scc(const dfa_t &dfa, std::stack< size_t > &stack, std::vector< size_t > &lowlink, std::vector< bool > &trivial, size_t i)
std::vector< dfa_state_t * > states
static void calc_fill(const dfa_t &dfa, const std::vector< bool > &trivial, std::vector< size_t > &fill, size_t i)
void fillpoints(const dfa_t &dfa, std::vector< size_t > &fill)
static const size_t UNDEFINED
static const size_t INFINITY
static bool loopback(size_t node, size_t narcs, const size_t *arcs)