def populate(self, <EOL>size, <EOL>names_library=None, <EOL>reuse_names=False,<EOL>random_branches=False, <EOL>branch_range=(<NUM_LIT:0>, <NUM_LIT:1>),<EOL>support_range=(<NUM_LIT:0>, <NUM_LIT:1>)):
NewNode = self.__class__<EOL>if len(self.children) > <NUM_LIT:1>:<EOL><INDENT>connector = NewNode()<EOL>for ch in self.get_children():<EOL><INDENT>ch.detach()<EOL>connector.add_child(child = ch)<EOL><DEDENT>root = NewNode()<EOL>self.add_child(child = connector)<EOL>self.add_child(child = root)<EOL><DEDENT>else:<EOL><INDENT>root = self<EOL><DEDENT>next_deq = deque([root])<EOL>for i in range(size-<NUM_LIT:1>):<EOL><INDENT>if random.randint(<NUM_LIT:0>, <NUM_LIT:1>):<EOL><INDENT>p = next_deq.pop()<EOL><DEDENT>else:<EOL><INDENT>p = next_deq.popleft()<EOL><DEDENT>c1 = p.add_child()<EOL>c2 = p.add_child()<EOL>next_deq.extend([c1, c2])<EOL>if random_branches:<EOL><INDENT>c1.dist = random.uniform(*branch_range)<EOL>c2.dist = random.uniform(*branch_range)<EOL>c1.support = random.uniform(*branch_range)<EOL>c2.support = random.uniform(*branch_range)<EOL><DEDENT>else:<EOL><INDENT>c1.dist = <NUM_LIT:1.0><EOL>c2.dist = <NUM_LIT:1.0><EOL>c1.support = <NUM_LIT:1.0><EOL>c2.support = <NUM_LIT:1.0><EOL><DEDENT><DEDENT>charset = "<STR_LIT>"<EOL>if names_library:<EOL><INDENT>names_library = deque(names_library)<EOL><DEDENT>else:<EOL><INDENT>avail_names = itertools.combinations_with_replacement(charset, <NUM_LIT:10>)<EOL><DEDENT>for n in next_deq:<EOL><INDENT>if names_library:<EOL><INDENT>if reuse_names:<EOL><INDENT>tname = random.sample(names_library, <NUM_LIT:1>)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>tname = names_library.pop()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>tname = '<STR_LIT>'.join(next(avail_names))<EOL><DEDENT>n.name = tname<EOL><DEDENT>
Generates a random topology by populating current node.

:argument None names_library: If provided, names library
  (list, set, dict, etc.) will be used to name nodes.

:argument False reuse_names: If True, node names will not be
  necessarily unique, which makes the process a bit more
  efficient.

:argument False random_branches: If True, branch distances and support
  values will be randomized.

:argument (0,1) branch_range: If random_branches is True, this
range of values will be used to generate random distances.

:argument (0,1) support_range: If random_branches is True,
this range of values will be used to generate random branch
support values.