Delay Tolerant Networks (DTNs), in which contacts between nodes come and go over time, is a promising approach to model communications in mobile ad-hoc networks, where scenarios of network partitioning and node disconnections are likely to happen. One of the most important challenges in such networks is how to route information and schedule transmissions, coping with the continuously changing network topology. In this paper, we focus on a deterministic and centralized DTN in which the contact times between nodes are known in advance or can be predicted; this model is applicable for various real-life scenarios. We provide a general framework for devising optimal routing algorithms to such networks under different objective functions and various real-life constraints (such as the available buffer and energy). The key insight is to model the DTN as an equivalent time-independent graph; this allows the usage of well-known algorithms and techniques to achieve optimal results. These algorithms can be also used as approximation for less certain settings or as benchmarks to evaluate other routing algorithms. In addition, we extended our framework to deal with long-lived DTNs in which contacts are periodic. Our algorithms are demonstrated by simulations, based directly on real-life traces, showing capacity-delay tradeoffs and the influence of the constraints and periodicity on the achievable throughput of the network.