code for closeness extraction