find weakly-connected components, store in networkx format