@staticmethod
    def kwayNormalisedCut(W, clustering):
        numVertices = W.shape[0]
        clusterIds = numpy.unique(clustering)

        Q = 0 
        for i in clusterIds:
            inds = numpy.arange(numVertices)[i==clustering]
            invInds = numpy.arange(numVertices)[i!=clustering]
            numClustEdges = float((W[inds, :]).sum())
            if (len(invInds) != 0) and (numClustEdges != 0): 
                Q += (W[inds, :][:, invInds]).sum()/numClustEdges
            
        Q = Q/clusterIds.shape[0]
        return Q
Do k-way normalised cut. Each cluster should have at least 1 edge. The input
dataset/ETHPy150Open charanpald/APGL/apgl/graph/GraphUtils.py/GraphUtils.kwayNormalisedCut