Colin Horne >
Algorithm-DependencySolver-0.1 >
Algorithm::DependencySolver::Traversal

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

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

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.

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.

`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).

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`

.

syntax highlighting: