The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Algorithm::DependencySolver::Traversal - A module for traversing a dependency graph

VERSION

version 1.01

SYNOPSIS

    my $traversal = Algorithm::DependencySolver::Traversal->new(
        Solver => $solver,
        visit  => sub {
            my $operation = shift;
            print "Visited operation: ", $operation->id, "\n";
        },
    );

    $traversal->run;

DESCRIPTION

Given an Algorithm::DependencySolver::Solver.pm object, traverses it in such a way that upon entering a node, all of its prerequisites will have already been entered.

Concurrency

Currently this module is not thread-safe. However, it has been design in such a way that it should be easy to allow concurrency at a later stage, without needing to break backwards compatibility.

Note that if we allow concurrency, the visitable list may be empty, without indicating that the traversal is complete.

METHODS

choose

During the traversal, we maintain a list of nodes, visitable, which can be immediately visited. If this list is empty, the traversal is complete.

The choose function is called to decide which node is visitable to visit next. Note that choose is guaranteed to be called, even if visitable is a singleton (but not if it's empty).

dryrun

Create a linear path and return it as an array of the arguments that would have been passed into the visit function.

Use run_path to run a path created by dryrun.