Energy harvesting (EH) has recently been attracting significant attention because of its ability to scavenge environmentally friendly energy. In this paper, we investigate the use of EH relay nodes to improve the quality of service (QoS) for relaying networks. To simplify the hardware design, we adopt a half-duplex selective decode-and-forward (SDF) relay. We propose a joint link selection and relay power allocation strategy to minimize the average outage probability. Both offline and online policies, i.e., with non-causal or causal side information about the energy state and the decoding result at the relay, are investigated by utilizing deterministic and stochastic dynamic programming (DP) algorithms, respectively. Furthermore, to reduce the complexity of the optimal online solution, we propose two low-complexity suboptimal online policies. Simulation results will show that the proposed suboptimal policies outperform the existing policies and achieve near optimal performance.