Algorithm-SixDegrees
view release on metacpan or search on metacpan
lib/Algorithm/SixDegrees.pm view on Meta::CPAN
The identifiers should be unique in datatype; that is, in an
actor/movie relationship, "Kevin Bacon" can be both the name of an
actor and a movie.
A linked data type must return identifiers that relate across the
link; that is, for an actor/movie relationship, an actor subroutine
should return movies, and a movie subroutine should return actors.
Additional arguments can be provided; these will be stored in the
object and passed through as the second and further arguments to
the subroutine. This may be useful, for example, if you're using
some form of results caching and need to pass a C<tie>d handle
around.
If you return explicit undef, please set C<$Algorithm::SixDegrees::ERROR>
with an error code. Explicit undef means that an error occurred
that should terminate the search; it should be returned as a
one-element list.
=head1 AUTHOR
samples/movie.pl view on Meta::CPAN
if(scalar(@chain)) {
print join (' -> ',@chain), "\n";
} else {
my $err = $Algorithm::SixDegrees::ERROR;
print $err ? "Error: $err\n" : "No chain found.\n";
}
my $format = $th ? '%0.2f' : '%0d';
printf "%5d database hits in $format second%s\n",$dbhit,($end-$start),(sprintf($format,$end-$start)==1?'':'s');
exit(0);
# returns either int or floating time depending on if Time::HiRes is installed
sub time {
return $th ? Time::HiRes::time() : time;
}
# Connects to the db and prepares the SQL for quick execution
sub db_connect {
$dbh = DBI->connect('DBI:mysql:database=movact','movact','movact');
( run in 0.552 second using v1.01-cache-2.11-cpan-39bf76dae61 )