From 33141e64b6a222d4825f11b422f8c893d64d3fee Mon Sep 17 00:00:00 2001 From: Justin Viiret Date: Thu, 29 Jun 2017 11:20:17 +1000 Subject: [PATCH] ng_netflow: use small_color_map --- src/nfagraph/ng_netflow.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/nfagraph/ng_netflow.cpp b/src/nfagraph/ng_netflow.cpp index cff26358..780a319f 100644 --- a/src/nfagraph/ng_netflow.cpp +++ b/src/nfagraph/ng_netflow.cpp @@ -1,5 +1,5 @@ /* - * 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: @@ -37,6 +37,7 @@ #include "ue2common.h" #include "util/container.h" #include "util/graph_range.h" +#include "util/graph_small_color_map.h" #include #include @@ -118,7 +119,7 @@ void removeEdgesFromIndex(NGHolder &g, vector &capacityMap, u32 idx) { * colour map (from which we can find the min cut). */ static u64a getMaxFlow(NGHolder &h, const vector &capacityMap_in, - vector &colorMap) { + decltype(make_small_color_map(NGHolder())) &colorMap) { vector capacityMap = capacityMap_in; NFAVertex src = h.start; NFAVertex sink = h.acceptEod; @@ -141,7 +142,6 @@ u64a getMaxFlow(NGHolder &h, const vector &capacityMap_in, vector edgeResiduals(numTotalEdges); vector predecessors(numVertices); vector distances(numVertices); - assert(colorMap.size() == numVertices); auto v_index_map = get(vertex_index, h); auto e_index_map = get(edge_index, h); @@ -151,7 +151,7 @@ u64a getMaxFlow(NGHolder &h, const vector &capacityMap_in, make_iterator_property_map(edgeResiduals.begin(), e_index_map), make_iterator_property_map(reverseEdges.begin(), e_index_map), make_iterator_property_map(predecessors.begin(), v_index_map), - make_iterator_property_map(colorMap.begin(), v_index_map), + colorMap, make_iterator_property_map(distances.begin(), v_index_map), v_index_map, src, sink); @@ -169,8 +169,8 @@ vector findMinCut(NGHolder &h, const vector &scores) { assert(hasCorrectlyNumberedEdges(h)); assert(hasCorrectlyNumberedVertices(h)); - vector colorMap(num_vertices(h)); - u64a flow = getMaxFlow(h, scores, colorMap); + auto colors = make_small_color_map(h); + u64a flow = getMaxFlow(h, scores, colors); vector picked_white; vector picked_black; @@ -185,17 +185,17 @@ vector findMinCut(NGHolder &h, const vector &scores) { continue; // skips, among other things, reverse edges } - default_color_type fromColor = colorMap[h[from].index]; - default_color_type toColor = colorMap[h[to].index]; + auto fromColor = get(colors, from); + auto toColor = get(colors, to); - if (fromColor != boost::white_color && toColor == boost::white_color) { + if (fromColor != small_color::white && toColor == small_color::white) { assert(ec <= INVALID_EDGE_CAP); DEBUG_PRINTF("found white cut edge %zu->%zu cap %llu\n", h[from].index, h[to].index, ec); observed_white_flow += ec; picked_white.push_back(e); } - if (fromColor == boost::black_color && toColor != boost::black_color) { + if (fromColor == small_color::black && toColor != small_color::black) { assert(ec <= INVALID_EDGE_CAP); DEBUG_PRINTF("found black cut edge %zu->%zu cap %llu\n", h[from].index, h[to].index, ec); @@ -206,7 +206,7 @@ vector findMinCut(NGHolder &h, const vector &scores) { DEBUG_PRINTF("min flow = %llu b flow = %llu w flow %llu\n", flow, observed_black_flow, observed_white_flow); - if (MIN(observed_white_flow, observed_black_flow) != flow) { + if (min(observed_white_flow, observed_black_flow) != flow) { DEBUG_PRINTF("bad cut\n"); }