BioPerl-Network

 view release on metacpan or  search on metacpan

lib/Bio/Network/ProteinNet.pm  view on Meta::CPAN

	$n;
}

=head2 is_forest

 Name      : is_forest
 Purpose   : Determine if a graph is a forest (2 or more trees)
 Usage     : if ($gr->is_forest){ ..... }
 Arguments : none
 Returns   : 1 or ""

=cut

sub is_forest {
	my $self = shift;
	return 1 if (!$self->is_connected && !$self->is_cyclic);
	return "";
}

=head2 is_tree

 Name      : is_tree
 Purpose   : Determine if the graph is a tree
 Usage     : if ($gr->is_tree){ ..... }
 Arguments : None
 Returns   : 1 or ""

=cut

sub is_tree {
	my $self = shift;
	return 1 if ($self->is_connected && !$self->is_cyclic);
	return "";
}

=head2 is_empty

 Name      : is_empty
 Purpose   : Determine if graph has no nodes
 Usage     : if ($gr->is_empty){ ..... }
 Arguments : None
 Returns   : 1 or ""

=cut

sub is_empty {
	my $self = shift;
	my @nodes = $self->vertices;
	return 1 if (scalar @nodes == 0);
	return "";
}

sub unconnected_nodes {
	my $self = shift;
	return $self->SUPER::isolated_vertices;
}

=head2 articulation_points

 Name      : articulation_points
 Purpose   : Find nodes in a graph that if removed will fragment
             the graph into sub-graphs.
 Usage     : my @nodes = $gr->articulation_points
                            or
             my $count = $gr->articulation_points
 Arguments : None
 Returns   : An array or a count of the array of nodes that will fragment 
             the graph if deleted. 
 Notes     : This method is currently broken due to bugs in Graph v. .69
             and later

=cut

sub articulation_points {
 	my $self = shift;
 	my @nodes = $self->SUPER::articulation_points; 
 	wantarray ? @nodes : scalar @nodes;
}

=head2 is_articulation_point

 Name      : is_articulation_point
 Purpose   : Determine if a given node is an articulation point or not. 
 Usage     : if ($gr->is_articulation_point($node)) {....}
 Arguments : A node (Sequence object)
 Returns   : 1 if node is an articulation point, 0 if it is not 
 Notes     : This method is currently broken due to bugs in Graph v. .69

=cut

sub is_articulation_point {
	my ($self,$node) = @_;

	$self->throw("$node is an incorrect parameter, not present in the graph")
		unless ( $node->isa("Bio::Network::Node") );
	
 	my @artic_points = $self->articulation_points();
 	grep /$node/,@artic_points ? return 1 : return 0;
}

=head2 nodes

 Name     : nodes
 Purpose  : Alias to Graph::vertices()
 Arguments: 
 Returns  : An integer
 Usage    : my $count = $graph->nodes;

=cut

sub nodes {
    my $self = shift;
	 if (wantarray) {
		 my @ns = $self->vertices;
		 return @ns;
	 } else {
		 return scalar $self->vertices;		 
	 }
}

=head2 has_node

 Name     : has_node
 Purpose  : Alias to Graph::has_vertex
 Arguments: 
 Returns  : True if the node exists
 Usage    : if ( $graph->has_node($node) ){ ... }



( run in 1.182 second using v1.01-cache-2.11-cpan-364913b4093 )