Algorithm::Graphs::Reachable::Tiny - Compute rechable nodes in a graph.
Version 0.01
use Algorithm::Graphs::Reachable::Tiny qw(all_reachable); my %g = ( 0 => {1 => undef}, 1 => {2 => undef, 4 => undef}, 2 => {3 => undef}, 4 => {5 => undef}, 6 => {7 => undef}, 7 => {8 => undef}, 8 => {9 => undef}, 9 => {7 => undef, 10 => undef} ); my $reachable = all_reachable(\%g, [4, 7]);
or
my $reachable = all_reachable(\%g, {4 => undef, 7 => undef});
Provides a function to determine all nodes reachable from a set of nodes in a graph.
A graph must be represented like this:
my $graph = { this => {that => undef, # ... }, # ... };
In this example, there is an edge from 'this' to 'that'. Note that you are not forced to use undef as hash value.
undef
GRAPH must be a reference to a hash. It represents the graph as described above. NODES must be a reference to a hash or an array.
GRAPH
NODES
The function determines all nodes in GRAPH that are reachable from one of the nodes in NODES. It returns a reference to a hash representing this set.
If NODES is empty, then the function returns an empty set.
If GRAPH is empty, then the returned set contains exactly the nodes in NODES.
If NODES contains elements that are not in GRAPH, then those elements are still in the result set.
Example:
my %g = ( 0 => {1 => undef}, 1 => {2 => undef, 4 => undef}, 2 => {3 => undef}, 4 => {5 => undef}, 6 => {7 => undef}, 7 => {8 => undef}, 8 => {9 => undef}, 9 => {7 => undef, 10 => undef} ); my $reachable = all_reachable(\%g, {4 => undef, 7 => undef});
$reachable containes:
$reachable
{ 4 => undef, 5 => undef, 7 => undef, 8 => undef, 9 => undef, 10 => undef, }
The following call would lead to the same result:
my $reachable = all_reachable(\%g, [4, 7]);
Abdul al Hazred, <451 at gmx.eu>
<451 at gmx.eu>
Please report any bugs or feature requests to bug-algorithm-graphs-reachable-tiny at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Graphs-Reachable-Tiny. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-algorithm-graphs-reachable-tiny at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Algorithm::Graphs::Reachable::Tiny
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Algorithm-Graphs-Reachable-Tiny
CPAN Ratings
https://cpanratings.perl.org/d/Algorithm-Graphs-Reachable-Tiny
Search CPAN
https://metacpan.org/release/Algorithm-Graphs-Reachable-Tiny
This software is copyright (c) 2022 by Abdul al Hazred.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Algorithm::Graphs::TransitiveClosure::Tiny, Graph, Text::Table::Read::RelationOn::Tiny
To install Algorithm::Graphs::Reachable::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::Graphs::Reachable::Tiny
CPAN shell
perl -MCPAN -e shell install Algorithm::Graphs::Reachable::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.