A Hamiltonian cycle or traceable cycle is a path that visits each vertex exactly once and returns to the starting vertex.
Given an Adjacency Matrix A, and a tour T, determine if the tour is Hamiltonian, ie a valid tour for the travelling salesman problem.
A is a matrix with 1 and 0 indicating presence of edge from ith vertex to jth vertex. T is a row vector representing the trip containing list of vertices visited in order. The trip from the last vertex in T to the first one is implicit.
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers40
Suggested Problems
-
Flip the main diagonal of a matrix
919 Solvers
-
middleAsColumn: Return all but first and last element as a column vector
652 Solvers
-
657 Solvers
-
Generate a vector like 1,2,2,3,3,3,4,4,4,4
14143 Solvers
-
Area of an equilateral triangle
6915 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!