Delay Tolerant Networks (DTNs) are novel wireless mobile networks, which suffer from frequent disruption, high latency, and the lack of a complete path from source to destination. Vehicular Delay Tolerant Network (VDTN) is a special type of DTNs with vehicles as nodes. In VDTN, most nodes have specific movement patterns, however, traditional routing algorithms in DTNs do not take this characteristic into considerations very well. In this paper, a new routing algorithm based on Bayesian Network (BN) is proposed to construct the prediction model, which intends to predict the movement patterns of nodes in the real VDTN scenarios. Firstly, a comprehensive BN model is established, where more attributes of nodes are selected to improve the accuracy of the model prediction. Then, considering the complexity of the structure learning problem of BN, a novel structure learning algorithm, K2 algorithm based on Genetic Algorithm (K2-GA), is proposed to search the optimal BN structure efficiently. At last, Junction Tree Algorithm (JTA) is adopted in the inference of BN, which can accelerate the inference process through variable elimination and calculation sharing for large scale BN. The simulation results show that the proposed VDTN routing algorithm based on the BN model can improve the delivery ratio with a minor forwarding overhead. INDEX TERMS Vehicular delay tolerant network, routing algorithm, Bayesian network, genetic algorithm, optimization.