def Density(adjmatrix):
    """Returns the density of links in a network.

    Parameters
    ----------
    adjmatrix : ndarray of rank-2
        The adjacency matrix of the network. Weighted links are ignored.

    Returns
    -------
    A scalar value between 0 and 1.
    """
    N = len(adjmatrix)
    L = adjmatrix.astype('bool').sum()
    if adjmatrix.trace():
        return float(L) / N ** 2
    else:
        return float(L) / (N * (N - 1))
