| 160 | } |
| 161 | |
| 162 | std::vector<El::Int> |
| 163 | breadth_first_search(El::Int root, |
| 164 | const std::map<El::Int, std::set<El::Int>>& edges) |
| 165 | { |
| 166 | |
| 167 | // Initialize data structures |
| 168 | std::unordered_map<El::Int, bool> is_visited; |
| 169 | std::vector<El::Int> sorted_nodes; |
| 170 | std::queue<El::Int> search_queue; |
| 171 | search_queue.push(root); |
| 172 | |
| 173 | // Visit nodes until search queue is exhausted |
| 174 | while (!search_queue.empty()) { |
| 175 | const auto& node = search_queue.front(); |
| 176 | search_queue.pop(); |
| 177 | for (const auto& neighbor : get_neighbors(node, edges)) { |
| 178 | if (!is_visited[neighbor]) { |
| 179 | is_visited[neighbor] = true; |
| 180 | sorted_nodes.push_back(neighbor); |
| 181 | search_queue.push(neighbor); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // Return list of sorted nodes |
| 187 | return sorted_nodes; |
| 188 | } |
| 189 | |
| 190 | std::vector<El::Int> |
| 191 | depth_first_search(El::Int root, |
nothing calls this directly
no test coverage detected