return false;
}
+ if (!hasNarrowReachVertex(g)) {
+ DEBUG_PRINTF("no narrow reach vertices\n");
+ return false;
+ }
+
if (hasLargeDegreeVertex(g)) {
DEBUG_PRINTF("large degree\n");
return false;
return false;
}
+bool hasNarrowReachVertex(const NGHolder &g, size_t max_reach_count) {
+ return any_of_in(vertices_range(g), [&](NFAVertex v) {
+ return !is_special(v, g) && g[v].char_reach.count() < max_reach_count;
+ });
+}
+
bool can_never_match(const NGHolder &g) {
assert(edge(g.accept, g.acceptEod, g).second);
if (in_degree(g.accept, g) == 0 && in_degree(g.acceptEod, g) == 1) {
/** True if g has any cycles which are not self-loops. */
bool hasBigCycles(const NGHolder &g);
+/**
+ * \brief True if g has at least one non-special vertex with reach smaller than
+ * max_reach_count. The default of 200 is pretty conservative.
+ */
+bool hasNarrowReachVertex(const NGHolder &g, size_t max_reach_count = 200);
+
/** Returns the set of all vertices that appear in any of the graph's cycles. */
std::set<NFAVertex> findVerticesInCycles(const NGHolder &g);
/* Avoid running the Violet analysis at all on graphs with no vertices with
* small reach, since we will not be able to extract any literals. */
- if (all_of_in(vertices_range(h), [&](NFAVertex v) {
- return is_special(v, h) || h[v].char_reach.count() >= 200;
- })) {
+ if (!hasNarrowReachVertex(h)) {
DEBUG_PRINTF("fail, no vertices with small reach\n");
return vg;
}