def generate2(self, graph, requireEmpty=True):
        Parameter.checkClass(graph, AbstractMatrixGraph)
        if requireEmpty and graph.getNumEdges()!= 0:
            raise ValueError("Graph must have no edges")
            
        numVertices = graph.getNumVertices()
        W = numpy.random.rand(numVertices, numVertices) < self.p
        W = numpy.array(W, numpy.int)
        
        if graph.isUndirected():
            diagW = numpy.diag(W)
            W = numpy.triu(W, 1)
            W = W + W.T
  
        
        graph.setWeightMatrix(scipy.sparse.csr_matrix(W, dtype=numpy.float))
            
        return graph
Generate sheets/variants
dataset/ETHPy150Open charanpald/APGL/apgl/generator/ErdosRenyiGenerator.py/ErdosRenyiGenerator.generate2--crossover with--dataset/ETHPy150Open zynga/jasy/jasy/asset/SpritePacker.py/SpritePacker.generate