in reply to Re^2: Partial sort for dependency graph
in thread Partial sort for dependency graph
Inefficiency is in the eye of the beholder anyway. If it turns out to be the difference between 10ms and 100ms on the problem in question then it probably doesn't matter...
To fill in the missing piece, I guess t_d_o could look something like (sadly untested, so apologies for any craziness):
Hmmm...in which case memoising might help a lot (on the recursive steps) - you'd end up storing approx N^2 t_d_o values (for N objects).sub t_d_o { my $s = shift; my $obj = shift; return 1 if $s eq $obj; # String compare on objects ok? foreach my $dependency ($s->dependencies) { return 1 if $dependency->t_d_o($obj); # Inf. loop on cycles. Whee. } return undef; }
|
|---|