updated to better enforce strongly connected graphs