def is_eulerian(G):
 if G.is_directed():
  return (all(((G.in_degree(n) == G.out_degree(n)) for n in G)) and nx.is_strongly_connected(G))
 return (all((((d % 2) == 0) for (v, d) in G.degree())) and nx.is_connected(G))

def is_eulerian ( G ) : if G . is_directed ( ) : return ( all ( ( ( G . in_degree ( n ) == G . out_degree ( n ) ) for n in G ) ) and nx . is_strongly_connected ( G ) ) return ( all ( ( ( ( d % 2 ) == 0 ) for ( v , d ) in G . degree ( ) ) ) and nx . is_connected ( G ) )
returns true if and only if g is eulerian .