# Cut graph at a given edge and return remaining subgraphs?

I would like to have a function that removes an edge from a graph and returns all remaining graphs after the operation. For example for a graph like

gr = Graph[{UndirectedEdge[y1, y2], UndirectedEdge[y2, y3],
UndirectedEdge[y2, y4], UndirectedEdge[y5, y3],
UndirectedEdge[y6, y3]}, VertexLabels -> Automatic]


It should return when splitting at the y2-y3 edge:

split[gr,UndirectedEdge[y2, y3]]


{

Graph[{UndirectedEdge[y1, y2], UndirectedEdge[y2, y4]}, VertexLabels -> Automatic]

,

Graph[{UndirectedEdge[y5, y3], UndirectedEdge[y6, y3]}, VertexLabels -> Automatic]

}

Or, it should return when splitting at the y1-y2 edge:

split[gr,UndirectedEdge[y1, y2]]


{

Graph[{y1}, {}, VertexLabels -> Automatic]

,

Graph[{ UndirectedEdge[y2, y3], UndirectedEdge[y2, y4], UndirectedEdge[y5, y3], UndirectedEdge[y6, y3]}, VertexLabels -> Automatic]

}

Is there a function in Mathematica that can do this? What is a quick way to do this?

gr2 = EdgeDelete[gr, UndirectedEdge[y2, y3]]


ConnectedComponents[gr2]


(*

{{y3, y5, y6}, {y1, y2, y4}}

*)

or ConnectedGraphComponents[gr2]

• That seems to return a single graph of two disconnected components. Can one get a list of several diconnected graphs instead? Commented Nov 15, 2018 at 20:43
• Ok, I think I got it: ConnectedGraphComponents[EdgeDelete[gr, UndirectedEdge[y2, y3]]]. Thank you for pointing this out! Commented Nov 15, 2018 at 20:45