def _laplacian_dense(graph, normed=False, return_diag=False):
    n_nodes = graph.shape[0]
    lap = (- np.asarray(graph))
    lap.flat[::(n_nodes + 1)] = 0
    w = (- lap.sum(axis=0))
    if normed:
        w = np.sqrt(w)
        w_zeros = (w == 0)
        w[w_zeros] = 1
        lap /= w
        lap /= w[:, np.newaxis]
        lap.flat[::(n_nodes + 1)] = (1 - w_zeros)
    else:
        lap.flat[::(n_nodes + 1)] = w
    if return_diag:
        return (lap, w)
    return lap
def _laplacian_dense(graph, normed=False, return_diag=False):
    n_nodes = graph.shape[0]
    lap = (- np.asarray(graph))
    lap.flat[::(n_nodes + 1)] = 0
    w = (- lap.sum(axis=0))
    if normed:
        w = np.sqrt(w)
        w_zeros = (w == 0)
        w[w_zeros] = 1
        lap /= w
        lap /= w[:, np.newaxis]
        lap.flat[::(n_nodes + 1)] = (1 - w_zeros)
    else:
        lap.flat[::(n_nodes + 1)] = w
    if return_diag:
        return (lap, w)
    return lap