# Pick a row for c1 in range(number_of_nodes-1): # Diagonal elements are null # So choose the column next to diagonal c2=c1+1 #check if it exists while not branch_map[c1][c2]: # If not move to next column c2=c2+1 # Check if the column is within dimensions if (c2>=number_of_nodes): # If not, break out and move to next row break else: # Starting branch found # Check is there are parallel branches between the nodes for c3 in range(len(branch_map[c1][c2])-1): loop_list.append([[c1, c2], [c1, c2]]) loop_count+=1 # Initialize the loop iterator list with the first element. loop_iter=[] loop_iter.append([[c1, c2]]) loop_count=find_loop(branch_map, loop_list, loop_iter, \ [c1, c2], loop_count)