def difference(G, H):
 if (not (G.is_multigraph() == H.is_multigraph())):
  raise nx.NetworkXError('G and H must both be graphs or multigraphs.')
 R = nx.create_empty_copy(G)
 R.name = ('Difference of (%s and %s)' % (G.name, H.name))
 if (set(G) != set(H)):
  raise nx.NetworkXError('Node sets of graphs not equal')
 if G.is_multigraph():
  edges = G.edges(keys=True)
 else:
  edges = G.edges()
 for e in edges:
  if (not H.has_edge(*e)):
   R.add_edge(*e)
 return R

def difference ( G , H ) : if ( not ( G . is_multigraph ( ) == H . is_multigraph ( ) ) ) : raise nx . NetworkXError ( 'G and H must both be graphs or multigraphs.' ) R = nx . create_empty_copy ( G ) R . name = ( 'Difference of (%s and %s)' % ( G . name , H . name ) ) if ( set ( G ) != set ( H ) ) : raise nx . NetworkXError ( 'Node sets of graphs not equal' ) if G . is_multigraph ( ) : edges = G . edges ( keys = True ) else : edges = G . edges ( ) for e in edges : if ( not H . has_edge ( * e ) ) : R . add_edge ( * e ) return R
returns all elements in seq1 which are not in seq2: i .