/*
- * Copyright (c) 2015-2016, Intel Corporation
+ * Copyright (c) 2015-2017, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
#include "util/graph_range.h"
#include "util/ue2_containers.h"
+#include <algorithm>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/reverse_graph.hpp>
template<class Graph>
static
bool searchForward(const Graph &g, const CharReach &reach,
+ vector<boost::default_color_type> &colours,
const flat_set<typename Graph::vertex_descriptor> &s,
typename Graph::vertex_descriptor w) {
- map<NFAVertex, boost::default_color_type> colours;
+ fill(colours.begin(), colours.end(), boost::white_color);
+ auto colour_map =
+ make_iterator_property_map(colours.begin(), get(vertex_index, g));
try {
- depth_first_visit(g, w, SearchVisitor(reach),
- make_assoc_property_map(colours),
- VertexInSet<typename Graph::vertex_descriptor, Graph>(s));
- } catch (SearchFailed&) {
+ depth_first_visit(g, w, SearchVisitor(reach), colour_map,
+ VertexInSet<typename Graph::vertex_descriptor, Graph>(s));
+ } catch (SearchFailed &) {
return false;
}
typedef typename Graph::vertex_descriptor vertex_descriptor;
+ // Colour map used for depth_first_visit().
+ vector<boost::default_color_type> colours(num_vertices(g));
+
// precalc successors of v.
flat_set<vertex_descriptor> succ_v;
insert(&succ_v, adjacent_vertices(v, g));
DEBUG_PRINTF(" - checking w %zu\n", g[w].index);
- if (!searchForward(g, reach, s, w)) {
+ if (!searchForward(g, reach, colours, s, w)) {
continue;
}
}
bool removeCyclicPathRedundancy(NGHolder &g) {
+ assert(hasCorrectlyNumberedVertices(g));
+
// Forward pass.
bool f_changed = cyclicPathRedundancyPass(g, g);
if (f_changed) {