adjusted community detection code to store also the out-edges