def setWeightMatrixSparse(self, W):
        """
        Set the weight matrix of this graph. Requires as input a scipy sparse matrix with the
        same dimensions as the current weight matrix. Edges are represented by
        non-zero edges.

        :param W:  The weight matrix to use. 
        """      
        
        if not isinstance(W, spmatrix.LLMatType) and not sparse.issparse(W):
            raise ValueError("Input must be a sparse matrix, not " + str(type(W)))

        if W.shape != (self.vList.getNumVertices(), self.vList.getNumVertices()):
            raise ValueError("Weight matrix has wrong shape : " + str(W.shape))
        
        try: 
            self.W = spmatrix.ll_mat(W.shape[0], W.shape[0], W.getnnz())
        except __HOLE__: 
            self.W = spmatrix.ll_mat(W.shape[0], W.shape[0], W.nnz)
      
        if isinstance(W, spmatrix.LLMatType): 
            #Warning: no check for symmetric matrix 
            #if self.undirected:
            #    raise ValueError("Weight matrix of undirected graph must be symmetric")
        
            items = W.items()
            
            for inds, val in items:
                self.W[inds[0], inds[1]] = val
        else: 
            if self.undirected and (W - W.transpose()).nonzero()[0].shape[0]:
                raise ValueError("Weight matrix of undirected graph must be symmetric")
            
            rowInds, colInds = W.nonzero()
                  
            for i in range(rowInds.shape[0]):
                self.W[int(rowInds[i]), int(colInds[i])] = W[int(rowInds[i]), int(colInds[i])]
dataset/ETHPy150Open charanpald/APGL/apgl/graph/PySparseGraph.py/PySparseGraph.setWeightMatrixSparse