def _max_cardinality_node(G, choices, wanna_connect):
 max_number = (-1)
 for x in choices:
  number = len([y for y in G[x] if (y in wanna_connect)])
  if (number > max_number):
   max_number = number
   max_cardinality_node = x
 return max_cardinality_node

def _max_cardinality_node ( G , choices , wanna_connect ) : max_number = ( - 1 ) for x in choices : number = len ( [ y for y in G [ x ] if ( y in wanna_connect ) ] ) if ( number > max_number ) : max_number = number max_cardinality_node = x return max_cardinality_node
returns a the node in choices that has more connections in g to nodes in wanna_connect .