# Code to find separating set in SageMath of a given Graph

Given a Graph $G$ how can I find the separating set of the Graph?

Suppose I am given this graph G=Graph({1:[2,3,4,5],2:[1,3,4,5],3:[1,2,4,5],4:[1,2,3],5:[1,2,3]})

I want to find the set of vertices whose removal disconnects the graph.

I found that the vertex connectivity of $G$ is 2.

Also on seeing the graph I find that the set of vertices whose removal disconnects the graph will be $(1,2,3)$

But how to find it using a code in SageMath?

edit retag close merge delete

Sort by ยป oldest newest most voted

Try this code:

from sage.graphs.connectivity import vertex_connectivity
G=Graph({1:[2,3,4,5],2:[1,3,4,5],3:[1,2,4,5],4:[1,2,3],5:[1,2,3]})
vertex_connectivity(G,value_only=False)


The result, running in a SageCell Server is

(3, [1, 2, 3])


Which says the vertex connectivity is 3 and the vertices 1,2,3 are such a set.

The documentation for vertex_connectivity() is here.

more

Thanks a lot sir. Can you kindly tell if there is any code which can find all the minimal separating sets of a given graph? How to write such a code

( 2019-08-05 00:53:28 -0500 )edit

I don't see anything in the documentation that would provide all minimal separating sets of a graph. Given that circulants would have a lot of vertex separating sets, I don't see any way around brute force checking whether the removal of k vertices (where k is the vertex connectivity) over all subsets of k vertices results in a disconnected graph. If so add to the list.

( 2019-08-05 09:52:55 -0500 )edit

Okay Thank you so much

( 2019-08-05 20:53:23 -0500 )edit