include("typedefs.jl")


function calc_D_MN(providers::Vector{Node}, clients::Vector{Node}, avg_speed::Float64)::Matrix{Int}
    m = length(providers)
    n = length(clients)

    D_MN = zeros(Int, (m, n))

    for k in range(1, stop=m)
        for i in range(1, stop=n)
            p = providers[k]
            c = clients[i]
            d_ki = round(hypot(p.cx-c.cx, p.cy-c.cy) / avg_speed)
            if (d_ki == 0) && (k != i)
                d_ki += 1
            end
            D_MN[k, i] = d_ki
        end
    end

    return D_MN
end


function calc_D_NN(clients::Vector{Node}, avg_speed::Float64)::Matrix{Int}
    n = length(clients)

    D_NN = zeros((n, n))

    for i in range(1, stop=n)
        for j in range(1, stop=n)
            c_outer = clients[i]
            c_inner = clients[j]
            d_ij = round(hypot(c_outer.cx-c_inner.cx, c_outer.cy-c_inner.cy) / avg_speed)
            if (d_ij == 0) && (i != j)
                d_ij += 1
            end
            D_NN[i, j] = d_ij
        end
    end

    return D_NN
end
