Changed comments
This commit is contained in:
parent
135120fa11
commit
4c02c31ef3
1 changed files with 9 additions and 8 deletions
17
hampath.py
17
hampath.py
|
@ -2,22 +2,23 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
start = 0; #Initial node for search \ start element in result chain.
|
#Initial node for search \ start element in result chain.
|
||||||
|
start = 0;
|
||||||
|
|
||||||
def deep (path):
|
def deep (path):
|
||||||
for i in range(0, len(matrix[0])): # len(matrix[0]) - number of iterations
|
for i in range(0, len(matrix[0])): # len(matrix[0]) - number of iterations
|
||||||
if matrix[path[-1]][i] != 0: # path[-1] - last element in chain
|
if matrix[path[-1]][i] != 0: # path[-1] - last element in chain
|
||||||
if i not in path: # if element not in chain already and has a connection w\ prev. node -- connect
|
if i not in path:
|
||||||
newPath = list(path) # a = b not equal a = copy(b) >_<
|
newPath = list(path) # a = b not equal a = copy(b) >_<
|
||||||
newPath.append(i)
|
newPath.append(i)
|
||||||
|
|
||||||
if len(newPath) == len(matrix[0]): #
|
if len(newPath) == len(matrix[0]):
|
||||||
if matrix[newPath[0]][newPath[-1]] != 0: # check connection for first and last nodes
|
if matrix[newPath[0]][newPath[-1]] != 0:
|
||||||
print newPath
|
print newPath
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
fin = deep ( newPath )
|
fin = deep ( newPath )
|
||||||
if fin == 1: # exit if path found
|
if fin == 1: # exit if path found
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue