I have a subgraph with some connected components as follows:
I'm using
bicomponents = list(nx.biconnected_components(T))
to identify all the connected components in the subgraph. I need to remove the whole connected component and contract that component to a vertex and get a new leaf. For example, I need to remove the component {28,30,31}
and introduce a new vertex 51
(I have n= 50
vertices, so new one will be 51
) and join with 29
to get a new leaf.
Can someone help me to do that?