App-War
view release on metacpan or search on metacpan
lib/App/War.pm view on Meta::CPAN
This property of the topological sort is used to ensure that we have a
unique ordering of the "combatants" in our "war".
=cut
sub tsort_not_unique {
my $self = shift;
# search for unordered items by calculating the topological sort and
# verifying that adjacent items are connected by a directed edge
my @ts = $self->graph->topological_sort;
for my $i (0 .. $#ts - 1) {
my ($u,$v) = @ts[$i,$i+1];
if (!$self->graph->has_edge($u,$v)) {
return [$u,$v];
}
}
return 0;
use Test::More tests => 4;
use_ok('App::War');
my @items = qw{ apple banana ceviche durian };
my $war = App::War->new();
$war->items(@items);
is_deeply([sort $war->items], \@items);
# verify that the graph vivifies
is($war->{graph},undef);
my $g = $war->graph;
isnt($war->{graph},undef);
$war->init;
( run in 0.286 second using v1.01-cache-2.11-cpan-73692580452 )