@not_implemented_for('undirected')
@not_implemented_for('multigraph')
def is_reachable(G, s, t):
 def two_neighborhood(G, v):
  'Returns the set of nodes at distance at most two from `v`.\n\n        `G` must be a graph and `v` a node in that graph.\n\n        The returned set includes the nodes at distance zero (that is,\n        the node `v` itself), the nodes at distance one (that is, the\n        out-neighbors of `v`), and the nodes at distance two.\n\n        '
  return {x for x in G if ((x == v) or (x in G[v]) or any((is_path(G, [v, z, x]) for z in G)))}
 def is_closed(G, nodes):
  'Decides whether the given set of nodes is closed.\n\n        A set *S* of nodes is *closed* if for each node *u* in the graph\n        not in *S* and for each node *v* in *S*, there is an edge from\n        *u* to *v*.\n\n        '
  return all(((v in G[u]) for u in (set(G) - nodes) for v in nodes))
 neighborhoods = [two_neighborhood(G, v) for v in G]
 return all(((not (is_closed(G, S) and (s in S) and (t not in S))) for S in neighborhoods))

@ not_implemented_for ( 'undirected' ) @ not_implemented_for ( 'multigraph' ) def is_reachable ( G , s , t ) : def two_neighborhood ( G , v ) : return { x for x in G if ( ( x == v ) or ( x in G [ v ] ) or any ( ( is_path ( G , [ v , z , x ] ) for z in G ) ) ) } def is_closed ( G , nodes ) : return all ( ( ( v in G [ u ] ) for u in ( set ( G ) - nodes ) for v in nodes ) ) neighborhoods = [ two_neighborhood ( G , v ) for v in G ] return all ( ( ( not ( is_closed ( G , S ) and ( s in S ) and ( t not in S ) ) ) for S in neighborhoods ) )
decides whether there is a path from s to t in the tournament .