### ----------------------------------------------------
### -- Graph
### -- Licenses: Artistic-2.0
### -- Authors: Anton Antonov
### -- File: t/13-topological-sort.rakutest
### ----------------------------------------------------
use v6.d;
use Test;

#use lib <. lib>;

use Graph;

subtest {
    my @edges = %('from' => 'B', 'to' => 'A', 'weight' => 1),
                %('from' => 'B', 'to' => 'E', 'weight' => 1),
                %('from' => 'C', 'to' => 'A', 'weight' => 1),
                %('from' => 'D', 'to' => 'B', 'weight' => 1),
                %('from' => 'D', 'to' => 'C', 'weight' => 1),
                %('from' => 'E', 'to' => 'A', 'weight' => 1),
                %('from' => 'E', 'to' => 'C', 'weight' => 1);

    my $g = Graph.new(@edges):d;
    is-deeply $g.topological-sort, <D B E C A>;
}

subtest {
    my @edges = %('from' => '1', 'to' => '2', 'weight' => 1),
                %('from' => '2', 'to' => '3', 'weight' => 1),
                %('from' => '3', 'to' => '4', 'weight' => 1),
                %('from' => '4', 'to' => '5', 'weight' => 1),
                %('from' => '5', 'to' => '1', 'weight' => 1);

    my $g = Graph.new(@edges):d;
    is-deeply $g.topological-sort, Empty;
}

done-testing;


