China's railway network is one of the largest railway networks in the world. By the end of 2016, the total length of railway in operation reached 124,000 km and the annual freight volume exceeded 3.3 billion tons. However, the structure of network does not completely match transportation demand, i.e., there still exist a few bottlenecks in the network, which forces some freight flows to travel along non-shortest paths. At present, due to the expansion of the high-speed railway network, more passengers will travel by electric multiple unit (EMU) trains running on the high-speed railway. Therefore, fewer passenger trains will move along the regular medium-speed lines, resulting in more spare capacity for freight trains. In this context, some shipments flowing on non-shortest paths can shift to shorter paths. And consequently, a combinatorial optimization problem concerning which origin-destination (O-D) pairs should be adjusted to their shortest paths will arise. To solve it, mathematical models are developed to adjust freight flows between their shortest paths and non-shortest paths based on the 0-1 knapsack problem. We also carry out computational experiments using the commercial software Gurobi and a greedy algorithm (GA), respectively. The results indicate that the proposed models are feasible and effective.