| 286 | return empty_graph(n) |
| 287 | |
| 288 | def _suitable(edges, potential_edges): |
| 289 | # Helper subroutine to check if there are suitable edges remaining |
| 290 | # If False, the generation of the graph has failed |
| 291 | if not potential_edges: |
| 292 | return True |
| 293 | for s1 in potential_edges: |
| 294 | for s2 in potential_edges: |
| 295 | # Two iterators on the same dictionary are guaranteed |
| 296 | # to visit it in the same order if there are no |
| 297 | # intervening modifications. |
| 298 | if s1 == s2: |
| 299 | # Only need to consider s1-s2 pair one time |
| 300 | break |
| 301 | if s1 > s2: |
| 302 | s1, s2 = s2, s1 |
| 303 | if (s1, s2) not in edges: |
| 304 | return True |
| 305 | return False |
| 306 | |
| 307 | def _try_creation(): |
| 308 | # Attempt to create an edge set |