Graph::Undirected::Hamiltonicity - decide whether a given Graph::Undirected contains a Hamiltonian Cycle.
Version 0.014
This module decides whether a given Graph::Undirected contains a Hamiltonian Cycle.
use Graph::Undirected; use Graph::Undirected::Hamiltonicity; # Create and initialize an undirected graph. my $g = Graph::Undirected->new( vertices => [ 0..3 ] ); $g->add_edge(0,1); $g->add_edge(0,3); $g->add_edge(1,2); $g->add_edge(1,3); if ( graph_is_hamiltonian( $g ) ) { say "The graph contains a Hamiltonian Cycle."; } else { say "The graph does not contain a Hamiltonian Cycle."; }
This module exports only one subroutine -- graph_is_hamiltonian()
Takes a Graph::Undirected object.
Returns 1 if the graph contains a Hamiltonian Cycle, 0 otherwise.
Please report issues on GitHub.
Ashwin Dixit, <ashwin at CPAN dot org>
<ashwin at CPAN dot org>
To install Graph::Undirected::Hamiltonicity, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Graph::Undirected::Hamiltonicity
CPAN shell
perl -MCPAN -e shell install Graph::Undirected::Hamiltonicity
For more information on module installation, please visit the detailed CPAN module installation guide.