Bio-ConnectDots
view release on metacpan or search on metacpan
lib/Bio/ConnectDots/SimpleGraph.pm view on Meta::CPAN
means you can get from any node of the component to any
other by following a path. 'Maximal' means that every node
you can reach from the component is in the component.
Args : None
Returns : ARRAY or ARRAY ref of SimpleGraphs
Note : The software caches the components once computed, so it's efficient
to call this repeatedly.
Title : shortest_paths
Usage : my $paths=$graph->shortest_paths;
while(my($endpoints,$path)=each %$paths) {
my($start,$stop)=split($;,$endpoints);
my @nodes_on_path=@$path;
print "Path from $start to $stop: @$nodes_on_path\n";
}
-- OR --
my ($paths,$distances)=$graph->shortest_paths(-want_distances=>1);
while(my($endpoints,$path)=each %$paths) {
my $distance=$distances->{$endpoints};
my($start,$stop)=split($;,$endpoints);
my @nodes_on_path=@$path;
print "Path from $start to $stop, distance $distance: @$nodes_on_path\n";
}
Function: Compute shortest path between each pair of nodes.
Args : (optional)
-max=>Maximum path length to compute
Paths longer than this are not found
-want_distances=>Boolean. If true, distances are also returned
Returns : HASH whose keys are pairs of nodes (encoded in the standard
Perl manner as two strings joined by $;) and whose values
are paths. Each path is an ARRAY ref of nodes starting at
the first endpoint and ending at the second.
The first endpoint is always lexically smaller (lt) than
the second.
If -want_distances is specified, the result is a pair of
HASHes, one containing paths and the other containing
distances.
Title : distances
Usage : my $distances=$graph->distances;
while(my($endpoints,$distance)=each %$distances) {
my($start,$stop)=split($;,$endpoints);
print "Path from $start to $stop has distance $distance\n";
}
-- OR --
my ($paths,$distances)=$graph->distances(-want_paths=>1);
while(my($endpoints,$distance)=each %$distances) {
my $path=$paths->{$endpoints};
my($start,$stop)=split($;,$endpoints);
my @nodes_on_path=@$path;
print "Path from $start to $stop, distance $distance: @$nodes_on_path\n";
}
Function: Compute distance between each pair of nodes. This is the
length of the shortest path
Args : (optional)
-max=>Maximum path length to compute
Distances longer than this are not found
-want_paths=>Boolean. If true, paths are also returned
Returns : HASH whose keys are pairs of nodes (encoded in the standard
Perl manner as two strings joined by $;) and whose values
are distances.
The first endpoint is always lexically smaller (lt) than
the second.
If -want_paths is specified, the result is a pair of
HASHes, one containing paths and the other containing
distances.
Title : connected_nodesets
Usage : my @nodesets=$graph->connected_nodesets;
for my $nodeset (@nodesets) {
my @nodes=@$nodeset;
( run in 0.467 second using v1.01-cache-2.11-cpan-b61123c0432 )