def nb_arcs_from_density(n: int, d: int) -> int:
    """
    Determines how many arcs in a directed graph of n and density d.
    Using a function I derived that had the follow characteristics
    m(d=0) = n, m(d=0.5) = (n)n-1/2 + 1, m(d=1) = n(n-1)
    """
    assert n > 1
    assert 0 <= d <= 1
    return round((2 * n - 4) * d ** 2 + d * (n - 2) ** 2 + n)