Graph-Fast

 view release on metacpan or  search on metacpan

t/04_dijkstra.t  view on Meta::CPAN

# how about we go find a way between two nodes that are unreachable, due
# to directionality?
is_deeply([$g->dijkstra("B", "A")], [], "returns empty list when there is no path");

# and between nodes that don't exist?
is_deeply([$g->dijkstra("B", "X")], [], "returns empty list for unknown nodes pt. 1");
is_deeply([$g->dijkstra("X", "B")], [], "returns empty list for unknown nodes pt. 2");

# test usage of a different queue module - here: dummy module that returns nothing
# and will therefore cause failure to find a path
{ package NullQueue; sub insert { } sub update { } sub pop { undef; } sub delete { } }
$g->{_queue_maker} = sub { bless({}, "NullQueue"); };
is_deeply([$g->dijkstra("A", "B")], [], "can use different queue module");

# here: actual module, should return same result now.
SKIP: {
	eval { require List::PriorityQueue };
	skip("List::PriorityQueue not installed, can't test with different queue module", 1) if ($@);

	$g->{_queue_maker} = sub { List::PriorityQueue->new() };
	is_deeply([$g->dijkstra("A", "B")], [{ from => "A", to => "E", weight => 2 }, { from => "E", to => "B", weight => 2 }], "different queue module works");

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.518 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )