def connected_watts_strogatz_graph(n, k, p, tries=100, seed=None):
 for i in range(tries):
  G = watts_strogatz_graph(n, k, p, seed)
  if nx.is_connected(G):
   return G
 raise nx.NetworkXError('Maximum number of tries exceeded')

def connected_watts_strogatz_graph ( n , k , p , tries = 100 , seed = None ) : for i in range ( tries ) : G = watts_strogatz_graph ( n , k , p , seed ) if nx . is_connected ( G ) : return G raise nx . NetworkXError ( 'Maximum number of tries exceeded' )
returns a connected watts–strogatz small-world graph .