http://www.perlmonks.org?node_id=320051


in reply to Depth First Search through Digraph Results in Memory Leak

I just noted a different bug in your code, in sub DFS

$explored->{$node->{_id}}++; foreach my $link (@{$node->{_outlinks}}) { $do_search->($link->{_to}) unless ($explored->{$link->{_id}}); }
should be
$explored->{$node->{_id}}++; foreach my $link (@{$node->{_outlinks}}) { $do_search->($link->{_to}) unless ($explored->{$link->{_to}{_id}}); # we stored the node id, not the link id in $explored ^^^^^ }

-- Hofmator