def general_random_intersection_graph(n, m, p):
 if (len(p) != m):
  raise ValueError('Probability list p must have m elements.')
 G = nx.empty_graph((n + m))
 mset = range(n, (n + m))
 for u in range(n):
  for (v, q) in zip(mset, p):
   if (random.random() < q):
    G.add_edge(u, v)
 return nx.projected_graph(G, range(n))

def general_random_intersection_graph ( n , m , p ) : if ( len ( p ) != m ) : raise ValueError ( 'Probability list p must have m elements.' ) G = nx . empty_graph ( ( n + m ) ) mset = range ( n , ( n + m ) ) for u in range ( n ) : for ( v , q ) in zip ( mset , p ) : if ( random . random ( ) < q ) : G . add_edge ( u , v ) return nx . projected_graph ( G , range ( n ) )
return a random intersection graph with independent probabilities for connections between node and attribute sets .