def find_alternating_4_cycle(G):
 for (u, v) in G.edges():
  for w in G.nodes():
   if ((not G.has_edge(u, w)) and (u != w)):
    for x in G.neighbors(w):
     if ((not G.has_edge(v, x)) and (v != x)):
      return [u, v, w, x]
 return False

def find_alternating_4_cycle ( G ) : for ( u , v ) in G . edges ( ) : for w in G . nodes ( ) : if ( ( not G . has_edge ( u , w ) ) and ( u != w ) ) : for x in G . neighbors ( w ) : if ( ( not G . has_edge ( v , x ) ) and ( v != x ) ) : return [ u , v , w , x ] return False
returns false if there arent any alternating 4 cycles .