refactor GirvanNewman algorithm