def latapy_clustering(G, nodes=None, mode='dot'):
 if (not nx.algorithms.bipartite.is_bipartite(G)):
  raise nx.NetworkXError('Graph is not bipartite')
 try:
  cc_func = modes[mode]
 except KeyError:
  raise nx.NetworkXError('Mode for bipartite clustering must be: dot, min or max')
 if (nodes is None):
  nodes = G
 ccs = {}
 for v in nodes:
  cc = 0.0
  nbrs2 = (set([u for nbr in G[v] for u in G[nbr]]) - set([v]))
  for u in nbrs2:
   cc += cc_func(set(G[u]), set(G[v]))
  if (cc > 0.0):
   cc /= len(nbrs2)
  ccs[v] = cc
 return ccs

def latapy_clustering ( G , nodes = None , mode = 'dot' ) : if ( not nx . algorithms . bipartite . is_bipartite ( G ) ) : raise nx . NetworkXError ( 'Graph is not bipartite' ) try : cc_func = modes [ mode ] except KeyError : raise nx . NetworkXError ( 'Mode for bipartite clustering must be: dot, min or max' ) if ( nodes is None ) : nodes = G ccs = { } for v in nodes : cc = 0.0 nbrs2 = ( set ( [ u for nbr in G [ v ] for u in G [ nbr ] ] ) - set ( [ v ] ) ) for u in nbrs2 : cc += cc_func ( set ( G [ u ] ) , set ( G [ v ] ) ) if ( cc > 0.0 ) : cc /= len ( nbrs2 ) ccs [ v ] = cc return ccs
compute a bipartite clustering coefficient for nodes .