summaryrefslogtreecommitdiff
path: root/regress/usr.bin/tsort/build-tree
blob: c38ab10dbdc87c4577af1f38b4ce74eb0bfe8b6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl

# Written by Marc Espie, 2001
# Public domain

# This does build tree of a given depth and breadth, to check on tsort's
# efficiency

$depth=shift;
$breadth=shift;


sub build_tree
{
    my $root = shift;
    my $depth = shift;

    my $leaf = 'a';
    my $i;

    for ($i = 0; $i < $breadth; $i++) {
	    print "$root $root$leaf\n";
	    build_tree($root.$leaf, $depth-1) if $depth > 0;
	    $leaf++;
    }
}

build_tree('a', $depth) if $depth > 0;