def _check_path(p):
 for (a, b) in zip(p[:(-1)], p[1:]):
  if (adjacency[a[0]][b[0]] != a[2]):
   return False
  if (adjacency[b[0]][a[0]] != b[1]):
   return False
 return True

def _check_path ( p ) : for ( a , b ) in zip ( p [ : ( - 1 ) ] , p [ 1 : ] ) : if ( adjacency [ a [ 0 ] ] [ b [ 0 ] ] != a [ 2 ] ) : return False if ( adjacency [ b [ 0 ] ] [ a [ 0 ] ] != b [ 1 ] ) : return False return True
make sure that a path is actually a string of nodes with connected ports returns true if path is valid .