| 1 | initial version |
I'm not sure if the following code is any faster, but it's purely in Sage without using any additional modules:
def remove_cc(G,S):
H = G.copy()
H.delete_vertices(S)
return H.connected_components_number()
def toughness(G):
return min(len(S)/c for S in Subsets(G.vertices()) if (c:=remove_cc(G,S))>=2)
print( toughness(graphs.CycleGraph(20)) )
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.