| 359 | } |
| 360 | |
| 361 | bool GraphCycles::CanContractEdge(int32 a, int32 b) { |
| 362 | CHECK(HasEdge(a, b)) << "No edge exists from " << a << " to " << b; |
| 363 | RemoveEdge(a, b); |
| 364 | bool reachable = IsReachableNonConst(a, b); |
| 365 | // Restore the graph to its original state. |
| 366 | InsertEdge(a, b); |
| 367 | // If reachable, then contracting edge will cause cycle. |
| 368 | return !reachable; |
| 369 | } |
| 370 | |
| 371 | bool GraphCycles::ContractEdge(int32 a, int32 b) { |
| 372 | CHECK(HasEdge(a, b)); |