xref: /openbsd/regress/usr.bin/tsort/build-tree (revision f6aab3d8)
1#!/usr/bin/perl
2
3# Written by Marc Espie, 2001
4# Public domain
5
6# This does build tree of a given depth and breadth, to check on tsort's
7# efficiency
8
9$depth=shift;
10$breadth=shift;
11
12
13sub build_tree
14{
15    my $root = shift;
16    my $depth = shift;
17
18    my $leaf = 'a';
19    my $i;
20
21    for ($i = 0; $i < $breadth; $i++) {
22	    print "$root $root$leaf\n";
23	    build_tree($root.$leaf, $depth-1) if $depth > 0;
24	    $leaf++;
25    }
26}
27
28build_tree('a', $depth) if $depth > 0;
29