1 < ($scope = 0 + $scope) or die "nearword scope must be greater than 1"; open $file, "<", $filename or die "cannot open text file for nearword: $!"; $nl <= $n && $n <= $nle or die "postcondition failed"; @a or die "internal error: quantile1 called on empty list, n=" . $n; @{$hheap[1]} and # DEBUG die "internal error: couldn't pop non-empty hheap"; $used{$q}++ and warn "single-link internal: used hash corrupt"; @order == @point && @gap == @order or die "singlelink internal error: lost or duplicate elements: order " . @order . ", point " . @point . ", gap " . @gap; keys(%$hash) == @$heap or die "assertion failed: hheap size mismatch: hash " . keys(%$hash) . ", heap " . @$heap; for $k (0 .. @$heap - 1) { ref($$heap[$k]) eq "ARRAY" or die "assertion failed: non-array heap element index " . $k; exists($$hash{${$$heap[$k]}[1]}) or warn("assertion failed: hheap element missing from hash: "), die "index " . $k . ", element " . ${$$heap[$k]}[1] . ", distance " . ${$$heap[$k]}[0]; $k == $$hash{${$$heap[$k]}[1]} or warn("assertion failed: hheap index mismatch: "), die " real index " . $k . ", element " . ${$$heap[$k]}[1] . ", hash value " . $$hash{${$$heap[$k]}[1]}; ${$$heap[($k - 1) >> 1]}[0] <= ${$$heap[$k]}[0] or warn("assertion failed: hheap heap mismatch: "), die "parent index " . $k . ", element " . ${$$heap[$k]}[1] . ", distance " . ${$$heap[$k]}[0] . ", child index " . (($k - 1) >> 1) . ", element " . ${$$heap[($k - 1) >> 1]}[1] . ", distance " . ${$$heap[($k - 1) >> 1]}[0]; 1 == @ARGV or die "Usage: rock-cut -g goal hierarchy.xml"; length($id) or die "invalid input: element with no id"; exists($element{$id}) and die qq[invalid input: duplicate element id "$id"]; length($id) or die "invalid input: cluster without id"; exists($cluster{$id}) and die qq[invalid input: duplicate cluster id "$id"]; @root or die(@root ? "error: no root clusters found -- wierd" : "error: no clusters found at all"); exists($$d{"weight"}) and do { if (defined($$d{"weight"})) { warn qq[warning: cluster included in more than one cluster: "$n"]; } else { die qq[error: circular clusters: "$n"]; } }; { warn qq[cluster "$c" has non-existent child "$cd"]; next; }; defined($mi) or do { warn "clusters fragmented totally, decrease goal or outlier_max"; last; };