| 445 | return leaf_nodes_sorted.pop() |
| 446 | |
| 447 | def use_longest_path() -> bool: |
| 448 | size = 0 |
| 449 | # Heavy reducer / splitter topologies often benefit from a very |
| 450 | # traditional critical path that expresses the longest chain of |
| 451 | # tasks. |
| 452 | if abs(len(root_nodes) - len(leaf_nodes)) / len(root_nodes) < 0.8: |
| 453 | # If the graph stays about the same, we are checking for symmetry |
| 454 | # and choose a "quickest path first" approach if the graph appears |
| 455 | # to be asymmetrical |
| 456 | for r in root_nodes: |
| 457 | if not size: |
| 458 | size = len(leafs_connected[r]) |
| 459 | elif size != len(leafs_connected[r]): |
| 460 | return False |
| 461 | |
| 462 | return True |
| 463 | |
| 464 | # Some topologies benefit if the node with the most dependencies |
| 465 | # is used as first choice, others benefit from the opposite. |