| 276 | } |
| 277 | |
| 278 | Status GraphAnalyzer::CollateResult() { |
| 279 | ordered_collation_.clear(); |
| 280 | collation_map_.clear(); |
| 281 | |
| 282 | // Collate by the signatures of the graphs. |
| 283 | for (const auto& it : result_) { |
| 284 | auto sig = absl::make_unique<Signature>(); |
| 285 | it->ExtractForSignature(&sig->map); |
| 286 | Status status = sig->Compute(); |
| 287 | if (!status.ok()) { |
| 288 | return status; |
| 289 | } |
| 290 | |
| 291 | auto& coll_entry = collation_map_[sig.get()]; |
| 292 | if (coll_entry.sig == nullptr) { |
| 293 | coll_entry.sig = std::move(sig); |
| 294 | } |
| 295 | ++coll_entry.count; |
| 296 | } |
| 297 | |
| 298 | // Then order them by the count. |
| 299 | for (auto& entry : collation_map_) { |
| 300 | ordered_collation_.insert(&entry.second); |
| 301 | } |
| 302 | |
| 303 | result_.clear(); // Not needed after collation. |
| 304 | |
| 305 | return Status::OK(); |
| 306 | } |
| 307 | |
| 308 | std::vector<string> GraphAnalyzer::DumpRawSubgraphs() { |
| 309 | std::vector<string> result; |