Challenges in relay selection for device-to-device (D2D) communication arise due to the mobility of nodes, which brings uncertainty in various network parameters. We first developed a network-assisted stochastic integer programming (SIP) model to incorporate uncertainty that predicts the network parameters for upcoming time instance based on information available at current time instance. We converted the SIP model to an equivalent deterministic mixed integer non-linear program (MINLP) model and proved its hardness result. By exploiting the constraints of MINLP, we developed a distributed greedy metric, termed as connectivity factor (CF), which is calculated locally at each node on per-hop basis. It captures the nodes mobility and, hence, takes care of link reliability that in turn controls packet loss and delay. It can be computed in O ( n ) time, where n is the number of transmitters interfering with the given link. Our approach is applicable to any mobility model with relevant distributions of mobility parameters known. We constructed perceived graph based on CF values to devise network-assisted and device-controlled relay selection algorithms for given source-destination pairs. Extensive simulation results show significant improvements in packet loss and average end-to-end delay by our approach over a recent implementation of an ad-hoc on-demand distance vector (AODV) based algorithm.