def from_nested_tuple(sequence, sensible_relabeling=False):
 def _make_tree(sequence):
  'Recursively creates a tree from the given sequence of nested\n        tuples.\n\n        This function employs the :func:`~networkx.tree.join` function\n        to recursively join subtrees into a larger tree.\n\n        '
  if (len(sequence) == 0):
   return nx.empty_graph(1)
  return nx.tree.join([(_make_tree(child), 0) for child in sequence])
 T = _make_tree(sequence)
 if sensible_relabeling:
  bfs_nodes = chain([0], (v for (u, v) in nx.bfs_edges(T, 0)))
  labels = {v: i for (i, v) in enumerate(bfs_nodes)}
  T = nx.relabel_nodes(T, labels)
 return T

def from_nested_tuple ( sequence , sensible_relabeling = False ) : def _make_tree ( sequence ) : if ( len ( sequence ) == 0 ) : return nx . empty_graph ( 1 ) return nx . tree . join ( [ ( _make_tree ( child ) , 0 ) for child in sequence ] ) T = _make_tree ( sequence ) if sensible_relabeling : bfs_nodes = chain ( [ 0 ] , ( v for ( u , v ) in nx . bfs_edges ( T , 0 ) ) ) labels = { v : i for ( i , v ) in enumerate ( bfs_nodes ) } T = nx . relabel_nodes ( T , labels ) return T
returns the rooted tree corresponding to the given nested tuple .