Optimal Resource Allocation in Multi-Hop Networks: Contention vs. Scheduling