It serialises a list of dependencies or it performs a topological sort on directed graph.
Perl 6
Switch branches/tags
Nothing to show
Latest commit ae14049 Apr 30, 2017 @jaffa4 jaffa4 Merge pull request #5 from zoffixznet/patch-1
Use modern META filename
Permalink
Failed to load latest commit information.
lib/Dependency missing files Jul 13, 2015
t Fix tests on current Rakudo Oct 17, 2015
.travis.yml Add Travis config Oct 17, 2015
META6.json Use modern META filename Apr 25, 2017
README.md Update README.md Jul 13, 2015

README.md

Dependency-Sort

This is a Perl6 module. It serialises a list of dependencies or it performs a topological sort on directed graph.

Example:

my %h; # this represents one node
my %g;
%h<itemid> = 1; # itemid should be unique for each rach
%g<itemid> = 2;
%h<name>   = '1';
%g<name>   = '2';

my %j  = ( "itemid", 3, "name", 3 );
my %j4 = ( "itemid", 4, "name", 4 );

my $s = Dependency::Sort.new();

$s.add_dependency( %h, %g ); # this means %h depends on %g
$s.add_dependency( %h, %j );

$s.add_dependency( %j, %j4 );
$s.add_dependency( %j, %g );

$s.add_dependency( %g, %j );


if !$s.serialise  # returns false if there is an error
{
  die $s.error_message; # the error message, meaning circular reference
}
else
{ # list of nodes in result... starting with independent ones.. then less dependent ones
  say $s.result.perl; # prints independent ones first
}