Wednesday, January 23, 2013

Loop identification -IX

The last circuit was short of one node because of an error in the node_checking function.

Here is the function:


The difference is caused by the last block:

if (row>0 and row<x_row-1 and col>0 and col<x_col-1):
    # If the element is not on the outer boundary
    if (x_mat[row][col+1]!='' and x_mat[row][col-1]!=''):
        # Check if the elements in next and
        # previous columns and same row are connected
        if (x_mat[row+1][col]!='' or x_mat[row-1][col]!=''):
            # Then check if elements in either the next and
            # previous row and same column are connected
            x_list.append([row, col])
    elif (x_mat[row+1][col]!='' and x_mat[row-1][col]!=''):
        # Check if the elements in next and
        # previous rows and same column are connected
        if (x_mat[row][col+1]!='' or x_mat[row][col-1]!=''):
            # Then check if elements in either the next and
            # previous column and same row are connected
            x_list.append([row, col])
The second elif statement had an extra indent!

No comments:

Post a Comment