used a networkx solution for get_components