def edge_boundary(G, nbunch1, nbunch2=None, data=False, keys=False, default=None):
 nset1 = {v for v in G if (v in nbunch1)}
 if G.is_multigraph():
  edges = G.edges(nset1, data=data, keys=keys, default=default)
 else:
  edges = G.edges(nset1, data=data, default=default)
 if (nbunch2 is None):
  return (e for e in edges if (e[1] not in nset1))
 nset2 = set(nbunch2)
 return (e for e in edges if (e[1] in nset2))

def edge_boundary ( G , nbunch1 , nbunch2 = None , data = False , keys = False , default = None ) : nset1 = { v for v in G if ( v in nbunch1 ) } if G . is_multigraph ( ) : edges = G . edges ( nset1 , data = data , keys = keys , default = default ) else : edges = G . edges ( nset1 , data = data , default = default ) if ( nbunch2 is None ) : return ( e for e in edges if ( e [ 1 ] not in nset1 ) ) nset2 = set ( nbunch2 ) return ( e for e in edges if ( e [ 1 ] in nset2 ) )
returns the edge boundary of nbunch1 .