diff options
Diffstat (limited to 'src/graph/algorithms/TopologicalSort.cpp')
-rw-r--r-- | src/graph/algorithms/TopologicalSort.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/graph/algorithms/TopologicalSort.cpp b/src/graph/algorithms/TopologicalSort.cpp index 3a69352471..08e14e1657 100644 --- a/src/graph/algorithms/TopologicalSort.cpp +++ b/src/graph/algorithms/TopologicalSort.cpp @@ -50,14 +50,14 @@ inline bool all_inputs_are_visited(const INode *node, const std::vector<bool> &v ARM_COMPUTE_ERROR_ON(graph == nullptr); bool are_all_visited = true; - for(const auto &input_edge_id : node->input_edges()) + for (const auto &input_edge_id : node->input_edges()) { - if(input_edge_id != EmptyNodeID) + if (input_edge_id != EmptyNodeID) { const Edge *input_edge = graph->edge(input_edge_id); ARM_COMPUTE_ERROR_ON(input_edge == nullptr); ARM_COMPUTE_ERROR_ON(input_edge->producer() == nullptr); - if(!visited[input_edge->producer_id()]) + if (!visited[input_edge->producer_id()]) { are_all_visited = false; break; @@ -80,9 +80,9 @@ std::vector<NodeID> bfs(Graph &g) std::list<NodeID> queue; // Push inputs and mark as visited - for(auto &input : g.nodes(NodeType::Input)) + for (auto &input : g.nodes(NodeType::Input)) { - if(input != EmptyNodeID) + if (input != EmptyNodeID) { visited[input] = true; queue.push_back(input); @@ -90,9 +90,9 @@ std::vector<NodeID> bfs(Graph &g) } // Push const nodes and mark as visited - for(auto &const_node : g.nodes(NodeType::Const)) + for (auto &const_node : g.nodes(NodeType::Const)) { - if(const_node != EmptyNodeID) + if (const_node != EmptyNodeID) { visited[const_node] = true; queue.push_back(const_node); @@ -100,7 +100,7 @@ std::vector<NodeID> bfs(Graph &g) } // Iterate over vector and edges - while(!queue.empty()) + while (!queue.empty()) { // Dequeue a node from queue and process NodeID n = queue.front(); @@ -109,11 +109,11 @@ std::vector<NodeID> bfs(Graph &g) const INode *node = g.node(n); ARM_COMPUTE_ERROR_ON(node == nullptr); - for(const auto &eid : node->output_edges()) + for (const auto &eid : node->output_edges()) { const Edge *e = g.edge(eid); ARM_COMPUTE_ERROR_ON(e == nullptr); - if(!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited)) + if (!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited)) { visited[e->consumer_id()] = true; queue.push_back(e->consumer_id()); @@ -135,9 +135,9 @@ std::vector<NodeID> dfs(Graph &g) std::stack<NodeID> stack; // Push inputs and mark as visited - for(auto &input : g.nodes(NodeType::Input)) + for (auto &input : g.nodes(NodeType::Input)) { - if(input != EmptyNodeID) + if (input != EmptyNodeID) { visited[input] = true; stack.push(input); @@ -145,9 +145,9 @@ std::vector<NodeID> dfs(Graph &g) } // Push const nodes and mark as visited - for(auto &const_node : g.nodes(NodeType::Const)) + for (auto &const_node : g.nodes(NodeType::Const)) { - if(const_node != EmptyNodeID) + if (const_node != EmptyNodeID) { visited[const_node] = true; stack.push(const_node); @@ -155,7 +155,7 @@ std::vector<NodeID> dfs(Graph &g) } // Iterate over vector and edges - while(!stack.empty()) + while (!stack.empty()) { // Pop a node from stack and process NodeID n = stack.top(); @@ -163,7 +163,7 @@ std::vector<NodeID> dfs(Graph &g) stack.pop(); // Mark node as visited - if(!visited[n]) + if (!visited[n]) { visited[n] = true; } @@ -171,11 +171,11 @@ std::vector<NodeID> dfs(Graph &g) const INode *node = g.node(n); ARM_COMPUTE_ERROR_ON(node == nullptr); // Reverse iterate to push branches from right to left and pop on the opposite order - for(const auto &eid : arm_compute::utils::iterable::reverse_iterate(node->output_edges())) + for (const auto &eid : arm_compute::utils::iterable::reverse_iterate(node->output_edges())) { const Edge *e = g.edge(eid); ARM_COMPUTE_ERROR_ON(e == nullptr); - if(!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited)) + if (!visited[e->consumer_id()] && detail::all_inputs_are_visited(e->consumer(), visited)) { stack.push(e->consumer_id()); } |