https://github.com/wtwhite/speedy_colorful_subtrees
Tip revision: 5acf83710cbd521310f3703dd22c59c1891b9574 authored by wtwhite on 16 March 2015, 06:47:49 UTC
Code for the Speedy Colorful Subtrees paper
Code for the Speedy Colorful Subtrees paper
Tip revision: 5acf837
smallest_weight_difference.pl
#!/usr/bin/perl
use strict;
use warnings;
<>;
<>;
<>;
<>; #HACK: Don't even care if we miss the first colour or not
my @weights;
while (<>) {
if (/\A(\d+)\s+(\d+)\s+([-+\d.eE]+)\s*\z/) {
push @weights, $3;
}
}
@weights = sort { $a <=> $b } @weights;
#print STDERR map { "$_\n" } @weights; #DEBUG
my $prev = shift @weights;
my $min = 1e9; # "Infinity"
foreach (@weights) {
$min = $_ - $prev if $_ - $prev < $min;
$prev = $_;
}
print "Minimum difference between any pair of edge weights: $min\n";