Bio-ConnectDots

 view release on metacpan or  search on metacpan

lib/Bio/ConnectDots/SimpleGraph.pm  view on Meta::CPAN

           traversal by creating a SimpleGraph::Traversal object
           directly.  The constructor is

           new Bio::ConnectDots::SimpleGraph::Traversal(-graph=>$graph,-start=>$start,
                                      -order=>$order,-what=>$what)

 Title   : node_traversal
 Usage   : my $traversal=$graph->node_traversal('a','depth first');
           my @nodes;
           while (my $node=$traversal->get_next) {
             push(@nodes,$node);
           }
           my $traversal=$graph->node_traversal('a','depth first');
           my @nodes=$traversal->get_all;
 Function: Do node traversal in depth or breadth first order.
           Wrapper for 'traversal' method. See above.
 Args    : (optional)
           $start: starting node for traversal
                   default: software picks arbitrary start
           $order: 'depth first' or 'breadth first' (actually,
                   anything starting with 'd' or 'b' will do)
                   default: 'depth first'
 Returns : SimpleGraph::Traversal object
 
 Title   : edge_traversal
 Usage   : my $traversal=$graph->edge_traversal(['a','b'],'depth first');
           my @edges;
           while (my $edge=$traversal->get_next) {
             push(@edges,$edge);
           }
           my $traversal=$graph->edge_traversal(['a','b'],'depth first');
           my @edges=$traversal->get_all;
 Function: Do edge traversal in depth or breadth first order.
           Wrapper for 'traversal' method. See above.
 Args    : (optional)
           $start: starting edge for traversal
                   default: software picks arbitrary start
           $order: 'depth first' or 'breadth first' (actually,
                   anything starting with 'd' or 'b' will do)
                   default: 'depth first'
 Returns : SimpleGraph::Traversal object

 Title   : components
 Usage   : my @components=$graph->components;
           for my $component (@components) {
             my @nodes=$component->nodes;
             my @edges=$component->edges;
           }
 Function: Compute the connected components of the graph.  A connected
           component is a maximal connected subgraph.  'Connected'
           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;
           }
 Function: Compute all sets of nodes that form connected subgraphs. 
           A connected nodeset is a set of nodes such that it's
           possible to get from any node to any other by following a
           path that only includes nodes in the set. 
 Args    : None
 Returns : ARRAY or ARRAY ref of nodeset, where each nodeset is an ARRAY
           ref of nodes.  
 Note    : Use with caution.  The number of nodesets is very
           large for graphs that are highly connected.

 Title   : connected_subgraphs
 Usage   : my @subgraphs=$graph->connected_subgraphs;
 Function: Compute all connected subgraphs of the current graph.
 Args    : None
 Returns : ARRAY or ARRAY ref of subgraphs
 Note    : Use with caution.  The number of connected subgraphs is
           very large for graphs that are highly connected.

=cut



( run in 0.897 second using v1.01-cache-2.11-cpan-5837b0d9d2c )