Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@@ -16,8 +16,8 @@ def valid_connection(
|
||||
Checks whether it is possible to add next into path by validating 2 statements
|
||||
1. There should be path between current and next vertex
|
||||
2. Next vertex should not be in path
|
||||
If both validations succeeds we return true saying that it is possible to connect this vertices
|
||||
either we return false
|
||||
If both validations succeeds we return True saying that it is possible to connect
|
||||
this vertices either we return False
|
||||
|
||||
Case 1:Use exact graph as in main function, with initialized values
|
||||
>>> graph = [[0, 1, 0, 1, 0],
|
||||
@@ -52,7 +52,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
|
||||
Pseudo-Code
|
||||
Base Case:
|
||||
1. Chceck if we visited all of vertices
|
||||
1.1 If last visited vertex has path to starting vertex return True either return False
|
||||
1.1 If last visited vertex has path to starting vertex return True either
|
||||
return False
|
||||
Recursive Step:
|
||||
2. Iterate over each vertex
|
||||
Check if next vertex is valid for transiting from current vertex
|
||||
@@ -74,7 +75,8 @@ def util_hamilton_cycle(graph: List[List[int]], path: List[int], curr_ind: int)
|
||||
>>> print(path)
|
||||
[0, 1, 2, 4, 3, 0]
|
||||
|
||||
Case 2: Use exact graph as in previous case, but in the properties taken from middle of calculation
|
||||
Case 2: Use exact graph as in previous case, but in the properties taken from
|
||||
middle of calculation
|
||||
>>> graph = [[0, 1, 0, 1, 0],
|
||||
... [1, 0, 1, 1, 1],
|
||||
... [0, 1, 0, 0, 1],
|
||||
|
||||
Reference in New Issue
Block a user