#NEWLINE# def normalisedLaplacianSym( self , outDegree = True , sparse = False ) : #NEWLINE# #INDENT# '\n        Compute the normalised symmetric laplacian matrix using L = I - D^-1/2 W D^-1/2,\n        in which W is the weight matrix and D_ii is the sum of the ith vertices weights.\n\n        :param outDegree: whether to use the out-degree for the computation of the degree matrix\n        :type outDegree: :class:`bool`\n\n        :param sparse: whether to return a sparse matrix or numpy array\n        :type sparse: :class:`bool`\n\n        :returns:  A normalised symmetric laplacian matrix\n        ' #NEWLINE# W = self . getSparseWeightMatrix ( ) #NEWLINE# if outDegree : #NEWLINE# #INDENT# degrees = numpy . array ( W . sum ( 1 ) ) . ravel ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# degrees = numpy . array ( W . sum ( 1 ) ) . ravel ( ) #NEWLINE# #UNINDENT# L = self . weightMatrixType ( ) ( ( self . getNumVertices ( ) , self . getNumVertices ( ) ) ) #NEWLINE# L . setdiag ( numpy . ones ( self . getNumVertices ( ) ) ) #NEWLINE# D2 = self . weightMatrixType ( ) ( ( self . getNumVertices ( ) , self . getNumVertices ( ) ) ) #NEWLINE# D2 . setdiag ( ( ( degrees + ( degrees == 0 ) ) ** ( - 0.5 ) ) ) #NEWLINE# L = ( L - D2 . dot ( W ) . dot ( D2 ) ) #NEWLINE# if ( sparse == True ) : #NEWLINE# #INDENT# return L #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return L . toarray ( )