Moved common values outside the for loop in louvain_step