NAME
Algorithm::TSort - Perl extension for topological sort
SYNOPSIS
use Algorithm::TSort;
# $adj = { 1 => [ 2, 3], 2 => [4], 3 => [4] } ;
my (@sorted ) = tsort( Graph( ADJ => $adj ). keys %$adj );
say for @sorted;
# -- OR --
# $adj_sub = sub { return unless $$adj->{ $_[0] } ; return @{$adj->{$_[0]}}; };
my (@sorted) = tsort( Graph( SUB => $adj_sub ), @nodes_for_sort );
# -- OR --
# $buf =
# "1 2 3
# 2 4
# 3 4";
my (@sorted) = tsort( Graph ( SCALAR => $buf ));
# -- OR --
#
my (@sorted) = tsort( Graph ( IO => \*STDIN) );
print "$_\n" for @sorted;
# -- OR --
# Write your own class for graph with 'adj_nodes' method
# my $graph = MyGraph->new;
# # Initialization ...
my (@sorted ) = tsort( $graph, @nodes_for_sort );
DESCRIPTION
Topological sort for varing inputs
EXPORT
Graph, tsort
SEE ALSO
AUTHOR
A. G. Grishaev, <grian@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2012 by A. G. Grishaev
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available.