/*
- * 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/container.h"
#include "util/graph.h"
#include "util/graph_range.h"
+#include "util/graph_small_color_map.h"
#include "util/report_manager.h"
#include <deque>
static
bool pruneForwardUseless(NGHolder &h, const nfag_t &g,
typename nfag_t::vertex_descriptor s,
- vector<default_color_type> &vertexColor) {
+ decltype(make_small_color_map(NGHolder())) &colors) {
// Begin with all vertices set to white, as DFV only marks visited
// vertices.
- fill(vertexColor.begin(), vertexColor.end(), boost::white_color);
+ colors.fill(small_color::white);
- auto index_map = get(&NFAGraphVertexProps::index, g);
-
- depth_first_visit(g, s, make_dfs_visitor(boost::null_visitor()),
- make_iterator_property_map(vertexColor.begin(),
- index_map));
+ depth_first_visit(g, s, make_dfs_visitor(boost::null_visitor()), colors);
vector<NFAVertex> dead;
// All non-special vertices that are still white can be removed.
for (auto v : vertices_range(g)) {
- u32 idx = g[v].index;
- if (!is_special(v, g) && vertexColor[idx] == boost::white_color) {
+ if (!is_special(v, g) && get(colors, v) == small_color::white) {
DEBUG_PRINTF("vertex %zu is unreachable from %zu\n",
g[v].index, g[s].index);
dead.push_back(NFAVertex(v));
void pruneUseless(NGHolder &g, bool renumber) {
DEBUG_PRINTF("pruning useless vertices\n");
assert(hasCorrectlyNumberedVertices(g));
- vector<default_color_type> vertexColor(num_vertices(g));
+ auto colors = make_small_color_map(g);
- bool work_done = pruneForwardUseless(g, g, g.start, vertexColor);
+ bool work_done = pruneForwardUseless(g, g, g.start, colors);
work_done |= pruneForwardUseless(g, reverse_graph<NGHolder, NGHolder &>(g),
- g.acceptEod, vertexColor);
+ g.acceptEod, colors);
if (!work_done) {
return;