#NEWLINE# def setWeightMatrix( self , W ) : #NEWLINE# #INDENT# '\n        Set the weight matrix of this graph. Requires as input an ndarray or \n        a scipy sparse matrix with the same dimensions as the current weight\n        matrix. Edges are represented by non-zero edges.\n\n        :param W: The weight matrix to use. \n        :type W: :class:`ndarray` or :class:`scipy.sparse` matrix\n        ' #NEWLINE# if ( W . shape != ( self . vList . getNumVertices ( ) , self . vList . getNumVertices ( ) ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Weight matrix has wrong shape : ' + str ( W . shape ) ) ) #NEWLINE# #UNINDENT# if ( self . undirected and ( type ( W ) == numpy . ndarray ) and ( W != W . T ) . any ( ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Weight matrix of undirected graph must be symmetric' ) #NEWLINE# #UNINDENT# if ( self . undirected and scipy . sparse . issparse ( W ) and ( not SparseUtils . equals ( W , W . T ) ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Weight matrix of undirected graph must be symmetric' ) #NEWLINE# #UNINDENT# self . W = self . weightMatrixType ( ) ( self )