R code to compute the expected force of a network node