AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs'
This was deprecated with version 2.1, and finally removed with version 2.4.
See these instructions
Use
(G.subgraph(c) for c in connected_components(G))
Or
(G.subgraph(c).copy() for c in connected_components(G))
connected_component_subgraphs
has been removed from the networkx library.
You can use the alternative described in the deprecation notice.
For your example, refer to the code below:
A = (B.subgraph(c) for c in nx.connected_components(B))
A = list(A)[0]