@not_implemented_for('directed')
def fiedler_vector(G, weight='weight', normalized=False, tol=1e-08, method='tracemin'):
 if (len(G) < 2):
  raise nx.NetworkXError('graph has less than two nodes.')
 G = _preprocess_graph(G, weight)
 if (not nx.is_connected(G)):
  raise nx.NetworkXError('graph is not connected.')
 if (len(G) == 2):
  return array([1.0, (-1.0)])
 find_fiedler = _get_fiedler_func(method)
 L = nx.laplacian_matrix(G)
 x = (None if (method != 'lobpcg') else _rcm_estimate(G, G))
 return find_fiedler(L, x, normalized, tol)[1]

@ not_implemented_for ( 'directed' ) def fiedler_vector ( G , weight = 'weight' , normalized = False , tol = 1e-08 , method = 'tracemin' ) : if ( len ( G ) < 2 ) : raise nx . NetworkXError ( 'graph has less than two nodes.' ) G = _preprocess_graph ( G , weight ) if ( not nx . is_connected ( G ) ) : raise nx . NetworkXError ( 'graph is not connected.' ) if ( len ( G ) == 2 ) : return array ( [ 1.0 , ( - 1.0 ) ] ) find_fiedler = _get_fiedler_func ( method ) L = nx . laplacian_matrix ( G ) x = ( None if ( method != 'lobpcg' ) else _rcm_estimate ( G , G ) ) return find_fiedler ( L , x , normalized , tol ) [ 1 ]
return the fiedler vector of a connected undirected graph .