def is_simple_path(G, nodes):
 if (len(nodes) == 0):
  return False
 if (len(nodes) == 1):
  return (nodes[0] in G)
 return ((len(set(nodes)) == len(nodes)) and all(((v in G[u]) for (u, v) in pairwise(nodes))))

def is_simple_path ( G , nodes ) : if ( len ( nodes ) == 0 ) : return False if ( len ( nodes ) == 1 ) : return ( nodes [ 0 ] in G ) return ( ( len ( set ( nodes ) ) == len ( nodes ) ) and all ( ( ( v in G [ u ] ) for ( u , v ) in pairwise ( nodes ) ) ) )
returns true if and only if the given nodes form a simple path in g .