Find all disconnected directed (cyclic) subgraphs and transform them into stars I have a graph $G=(V,E)$ that consists of many disconnected directed subgraphs, some of them may be cyclic. (Basically a "forest" consisting of directed trees and some directed disconnected cyclic graphs added into it). 

I want to find all of these disconnected subgraphs and turn them into stars given by the key of the node. 

I've built a directed graph (using Python's networkx library) and now I am kinda stuck how to find those disconnected subgraphs, because some of those subgraphs will have source and some of those wont. 

How to proceed? Thanks!
Probably you want to compute weakly connected components, a subgraph having a path between every two vertices in the underlying undirected graph. Computing the weakly connected components is easy: first transform the directed graph into undirected by removing "directions" of each edge and run DFS/BFS on that graph (by looping on vertices!). Alternatively, if you're interested in the strongly connected components then you should run one of the algorithms computing SCCs. This gives you components $C_1, \dots, C_n$. 

Then you can do whatever you want to do on these components.