{
assert(!graph.isBuildingPhase()); // Restrict iteration condition
- std::vector<bool> visited(graph.operations().size(), false);
+ std::unordered_map<operation::Index, bool> visited;
+ graph.operations().iterate(
+ [&](const operation::Index &index, NodeRef) { visited[index] = false; });
std::function<void(const operation::Index &, NodeRef)> dfs_recursive =
[&](const operation::Index &index, NodeRef node) -> void {
- if (visited[index.asInt()])
+ if (visited[index])
return;
- visited[index.asInt()] = true;
+ visited[index] = true;
for (auto output : node.getOutputs())
{
graph.operations().iterate(dfs_recursive);
// All of the operations(nodes) must have been visited.
- assert(std::all_of(visited.begin(), visited.end(), [](bool v) { return v; }));
+ assert(std::all_of(visited.begin(), visited.end(),
+ [](const std::pair<const operation::Index, bool> &v) { return v.second; }));
}
} // namespace graph