| 189 | } |
| 190 | |
| 191 | Status PruneForTargets(Graph* g, const NameIndex& name_index, |
| 192 | const std::vector<Node*>& fetch_nodes, |
| 193 | const gtl::ArraySlice<string>& target_nodes) { |
| 194 | string not_found; |
| 195 | std::unordered_set<const Node*> targets; |
| 196 | for (Node* n : fetch_nodes) { |
| 197 | if (!AddNodeToTargets(n->name(), name_index, &targets)) { |
| 198 | strings::StrAppend(¬_found, n->name(), " "); |
| 199 | } |
| 200 | } |
| 201 | for (const string& s : target_nodes) { |
| 202 | if (!AddNodeToTargets(s, name_index, &targets)) { |
| 203 | strings::StrAppend(¬_found, s, " "); |
| 204 | } |
| 205 | } |
| 206 | if (!not_found.empty()) { |
| 207 | return errors::NotFound("PruneForTargets: Some target nodes not found: ", |
| 208 | not_found); |
| 209 | } |
| 210 | PruneForReverseReachability(g, std::move(targets)); |
| 211 | |
| 212 | // Reconnect nodes with no outgoing edges to the sink node |
| 213 | FixupSourceAndSinkEdges(g); |
| 214 | |
| 215 | return Status::OK(); |
| 216 | } |
| 217 | |
| 218 | } // namespace |
| 219 |
no test coverage detected