mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-09 05:36:22 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -6,11 +6,10 @@
|
||||
|
||||
Wikipedia: https://en.wikipedia.org/wiki/Hamiltonian_path
|
||||
"""
|
||||
from typing import List
|
||||
|
||||
|
||||
def valid_connection(
|
||||
graph: List[List[int]], next_ver: int, curr_ind: int, path: List[int]
|
||||
graph: list[list[int]], next_ver: int, curr_ind: int, path: list[int]
|
||||
) -> bool:
|
||||
"""
|
||||
Checks whether it is possible to add next into path by validating 2 statements
|
||||
@ -47,7 +46,7 @@ def valid_connection(
|
||||
return not any(vertex == next_ver for vertex in path)
|
||||
|
||||
|
||||
def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int) -> bool:
|
||||
def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int) -> bool:
|
||||
"""
|
||||
Pseudo-Code
|
||||
Base Case:
|
||||
@ -108,7 +107,7 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
|
||||
return False
|
||||
|
||||
|
||||
def hamilton_cycle(graph: List[List[int]], start_index: int = 0) -> List[int]:
|
||||
def hamilton_cycle(graph: list[list[int]], start_index: int = 0) -> list[int]:
|
||||
r"""
|
||||
Wrapper function to call subroutine called util_hamilton_cycle,
|
||||
which will either return array of vertices indicating hamiltonian cycle
|
||||
|
Reference in New Issue
Block a user