Questions tagged [hamiltonian-cycle]

A Hamiltonian cycle is a cycle in a directed or undirected graph that visits each node/vertex exactly once.

115 questions
0
votes
2 answers

Find the final path of Traveling Salesman Problem

I am trying to implement the Traveling Salesman Problem and I need to return the path that lead to the minimum cost. I have a distance matrix, and this is the code: static int TSP(int[][] distance, boolean[] visitCity, int currPos, int cities, int…
0
votes
0 answers

Why cant we use algorithm to find all cycles to find an hamiltonian cycle?

I recently came across algorithms to find all cycles in an undirected graph, and was confused when i saw that they are running linear time (example), It seem easy to use one of these to find hamilton cycle (for each cycle we find just check if it is…
0
votes
0 answers

How to calculate all possible cycles (all nodes must be visited once) on a graph? Hamilton circle

I am trying to write a program which outputs all possible cycles starting and ending with node 1 and visiting all other nodes exactly once. Given is a complete undirected unweighted graph with N nodes. For example: n = 4 then 1-2-3-4, 1-2-4-3,…
0
votes
2 answers

What is the minimum degree of vertex required for each vertex to have a Hamiltonian cycle?

I googled it and found: If G = (V,E) has n ≥ 3 vertices and every vertex has degree ≥ n/2 then G has a Hamilton circuit. But my question is if the degree of each vertex is 2 or more, then the graph can also have a Hamiltonian Cycle. example:- …
Abhishek Jaiswal
  • 288
  • 2
  • 14
0
votes
1 answer

Removing a1 field from chess board in Clingo knight path program

I need to do some symulations about knight path and Hamilton cycle on chesseboard, but i wondering what if i exclude some fields from chesseboard xchessboard(1..8). ychessboard(1..8). time(1..8*8+1). xypos(X,Y) :- xchessboard(X),…
0
votes
1 answer

An efficient Algorithm for Hamiltonian circuit

I recently discovered the Hamiltonian Path/Circuit in CodeBullet's Snake A.I. video and decided to give it a go myself. I wrote a basic Depth First Search algorithm to visit all the nodes in a graph and store the path when the circuit is…
0
votes
1 answer

Ultra-Hamiltonian cycle

Ultra-Hamiltonian cycling is defined to be a closed walk that visits every vertex exactly once, except for at most one vertex that visits more than once. Question:- Prove that it is NP-hard to determine whether a given graph contains an…
0
votes
0 answers

what is a path which visits every vertex at least once called

As I understand it, a Hamiltonian path visits every vertex of a graph exactly once. Is there a name for a path which visits every vertex at least once? Some graphs may be such that a cycle visiting every vertex, must visit some vertices more than…
Jim Newton
  • 594
  • 3
  • 16
0
votes
0 answers

How a shortest path problem with negative cost cycles can be polynomially reduced to the Hamiltonian cycle problem to demonstrate NP-completeness

I know that if there are negative cost cycles in a graph, the relative shortest path problem belongs to the np-complete class. I need to prove this by performing a polynomial reduction using the Hamiltonian cycle problem. Could anyone explain it? It…
0
votes
1 answer

Prunning Strategies to compute the total number of hamiltonian paths in 2D grid

I was recently trying to come up with the total number of hamiltonian paths (basically starting for start vertex, visit each node exaactly once and reach the end vertex). Brute force dfs goes for a long walk on a moderate sized grid of 7x8. I came…
Amm Sokun
  • 1,298
  • 4
  • 20
  • 35
0
votes
2 answers

Problem in R studio while solving Traveling Salesman Problem (TSP) using Concorde

I am working with Concorde to solve TSP problems. Here is my code library(TSP) concordePath = "E:/Concorde_Code/" concorde_path(concordePath) concorde_help() dataset_path = "E:/RA/" name = "graph1.txt" dataset =…
0
votes
1 answer

Find a Hamiltonian cycle of no more than twice the minimum cost in O(m+n log n) in an undirected graph with costs satisfying the triangle inequality

So I've been given this task and I do not know how to use the information regarding the costs. This is the requirement and I have no additional information.
Andrei
  • 5
  • 3
0
votes
1 answer

Symmetric(or undirected) Hamiltonian Cycle data sets

I would like to test my recently created algorithm on large (50+ node) graphs. Preferrably, they would specifically be challenging graphs, and known tours would exist (for at least most of them). Problem sets for this problem do not seem as easy to…
Travis Black
  • 705
  • 7
  • 18
0
votes
0 answers

Hamiltonian Cycle - graph with specific conditions

I'm trying to do a lot of programming exercises to understand concepts and get hands-on experience practice by tackling them. I've stumbled upon an exercise that gives a set of conditions as to how the graph is like and requires you to find out…
Alias
  • 1
  • 1
0
votes
1 answer

TSP for a flights fares

I am trying to solve a Traveling-salesman problem with a flight fares, so main idea is to start from one Airport and visit all Airports only once and return to origin. So for example: Starting from LAX Visit LV, CA, NY End LAX. This is a classic…
hasskell
  • 441
  • 3
  • 7