} // namespace
-template<class GraphT>
+template<class Graph>
static
-void findLoopReachable(const GraphT &g,
- const typename GraphT::vertex_descriptor srcVertex,
- vector<bool> &deadNodes) {
- typedef typename GraphT::edge_descriptor EdgeT;
- typedef typename GraphT::vertex_descriptor VertexT;
- typedef set<EdgeT> EdgeSet;
+vector<bool> findLoopReachable(const Graph &g,
+ const typename Graph::vertex_descriptor src) {
+ vector<bool> deadNodes(num_vertices(g));
+
+ using Edge = typename Graph::edge_descriptor;
+ using Vertex = typename Graph::vertex_descriptor;
+ using EdgeSet = set<Edge>;
EdgeSet deadEdges;
BackEdges<EdgeSet> be(deadEdges);
- depth_first_search(g, visitor(be).root_vertex(srcVertex));
+ depth_first_search(g, visitor(be).root_vertex(src));
auto af = make_bad_edge_filter(&deadEdges);
auto acyclic_g = make_filtered_graph(g, af);
- vector<VertexT> topoOrder; /* actually reverse topological order */
+ vector<Vertex> topoOrder; /* actually reverse topological order */
topoOrder.reserve(deadNodes.size());
topological_sort(acyclic_g, back_inserter(topoOrder));
for (const auto &e : deadEdges) {
- u32 srcIdx = g[source(e, g)].index;
+ size_t srcIdx = g[source(e, g)].index;
if (srcIdx != NODE_START_DOTSTAR) {
deadNodes[srcIdx] = true;
}
}
- for (VertexT v : reverse(topoOrder)) {
+ for (auto v : reverse(topoOrder)) {
for (const auto &e : in_edges_range(v, g)) {
if (deadNodes[g[source(e, g)].index]) {
deadNodes[g[v].index] = true;
}
}
}
+
+ return deadNodes;
}
template <class GraphT>
* create a filtered graph for max depth calculations: all nodes/edges
* reachable from a loop need to be removed
*/
- vector<bool> deadNodes(numVertices);
- findLoopReachable(g, g.start, deadNodes);
+ auto deadNodes = findLoopReachable(g, g.start);
DEBUG_PRINTF("doing start\n");
calcAndStoreDepth(g, g.start, deadNodes, dMin, dMax, depths,
* create a filtered graph for max depth calculations: all nodes/edges
* reachable from a loop need to be removed
*/
- vector<bool> deadNodes(numVertices);
- findLoopReachable(rg, g.acceptEod, deadNodes);
+ auto deadNodes = findLoopReachable(rg, g.acceptEod);
DEBUG_PRINTF("doing accept\n");
calcAndStoreDepth<RevNFAGraph, NFAVertexRevDepth>(
* create a filtered graph for max depth calculations: all nodes/edges
* reachable from a loop need to be removed
*/
- vector<bool> deadNodes(numVertices);
- findLoopReachable(g, g.start, deadNodes);
+ auto deadNodes = findLoopReachable(g, g.start);
DEBUG_PRINTF("doing start\n");
calcAndStoreDepth<NGHolder, NFAVertexBidiDepth>(
/* Now go backwards */
typedef reverse_graph<NGHolder, const NGHolder &> RevNFAGraph;
const RevNFAGraph rg(g);
- deadNodes.assign(numVertices, false);
- findLoopReachable(rg, g.acceptEod, deadNodes);
+ deadNodes = findLoopReachable(rg, g.acceptEod);
DEBUG_PRINTF("doing accept\n");
calcAndStoreDepth<RevNFAGraph, NFAVertexBidiDepth>(
assert(hasCorrectlyNumberedVertices(g));
const size_t numVertices = num_vertices(g);
- vector<bool> deadNodes(numVertices);
- findLoopReachable(g, g.start, deadNodes);
+ auto deadNodes = findLoopReachable(g, g.start);
vector<int> dMin, dMax;
calcDepthFromSource(g, src, deadNodes, dMin, dMax);