Questions tagged [hamiltonian-cycle]

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

104 questions
2
votes
1 answer

GCJ - Hamiltonian Cycles

Code jam problem is the following: You are given a complete undirected graph with N nodes and K "forbidden" edges. N <= 300, K <= 15. Find the number of Hamiltonian cycles in the graph that do not use any of the K "forbidden" edges. Unfortunately…
2
votes
1 answer

Generate Adjacency matrix from a Map

I know this is a lengthy question :) I'm trying to implement Hamiltonian Cycle on a dataset in Scala 2.11, as part of this I'm trying to generate Adjacency matrix from a Map of values. Explanation: Keys 0 to 4 are the different cities, so in below…
Rohit Nimmala
  • 1,131
  • 5
  • 20
2
votes
1 answer

Time Complexity in code?

I have fun1 calls foo1() which takes O(n^6 + m^4). What do you think the time complexity of fun1? My guess is it would be O(2n^6 + m^4) !! int fun1(int n, int G[MAX][MAX]) { int x, ans; if(n < 2) return 1; for(x = 0; x < n; x++){ …
33ted
  • 667
  • 1
  • 5
  • 14
2
votes
1 answer

Recursive backtracking in Racket?

A while ago, as a proof of concept (and because I was using Logo with my autistic son) I wrote a program in Logo to find a Hamiltonian circuit in a graph (if it exists) using a backtracking method. The basic backtracking schema I used was: boolean…
Alasdair
  • 1,208
  • 1
  • 13
  • 26
2
votes
1 answer

Construct a graph containing a Hamiltonian path

Background I am working on an optimization problem and have managed to reduce the problem to checking if a graph contains a Hamiltonian path. The reduced problem is as follows: The problem We are given a sequence of edges (Example: e[1,5], e[3,4],…
lakshayg
  • 1,923
  • 2
  • 19
  • 31
2
votes
2 answers

Which crossing over method is best to give us quick changes in best values for TSP in GA?

I am trying to solve Travelling Salesman Problem using Genetic Algorithym in C#. But in my app best values changes so slowly. I have tried with different Crossing-Over methods such as classic, greedy and pmx but I have never got what I want. What is…
Ali Tor
  • 2,276
  • 1
  • 21
  • 47
2
votes
0 answers

Restricted Hamiltonian Cycle

Can someone explain to me the definition of a Restricted Hamiltonian Cycle? I know what a Hamiltonian Path (and a Hamiltonian Cycle) is, but I'm having a problem understanding a what is a Restricted Hamiltonian Cycle exactly. Thank you.
XandY
  • 43
  • 2
2
votes
2 answers

Find all possible hamiltonian cycles in a partially oriented graph

This is my algorithm to find a Hamiltonian cycle in a graph: private SolutionArray solution; private int V, pathCount; private int[] path; private int[][] graph; /** * Constructor */ public ConcreteSolver() { solution = new…
JulioQc
  • 312
  • 1
  • 3
  • 18
2
votes
2 answers

Is it possible to use Dijkstra's Shortest Path Algorithm to find the shortest Hamiltonian path? (in Polynomial Time)

I've read that the problem of finding whether a Hamiltonian path exists in a graph is NP-Complete, and since Dijkstra's Shortest Path Algorithm runs in Polynomial Time, it cannot be modified to find the shortest Hamiltonian path. (Is this logic…
2
votes
0 answers

Seeking samples of grid graphs with holes that are considered "difficult" for finding Hamiltonian cycle

Is there a database or citations for grid graphs with holes that are considered "difficult" to solve for Hamiltonian cycle?
2
votes
2 answers

Algorithm for Enumerating Hamiltonian Cycles of a Complete Graph (Permutations where loops, reverses, wrap-arounds or repeats don't count)

I want to generate all the Hamiltonian Cycles of a complete undirected graph (permutations of a set where loops and reverses count as duplicates, and are left out). For example, permutations of {1,2,3} are Standard…
ruya
  • 381
  • 3
  • 5
  • 12
2
votes
1 answer

Program to find number of hamiltonian paths in a graph given start and end points

Given a graph with n² pathing nodes, and given that the starting node is always in the top right corner (point A) and the ending node is always in the bottom right corner (point B), I need to write a C# program that will determine the number of…
Steve Holt
  • 59
  • 2
2
votes
2 answers

Checking if a Hamilton Cycle exists in a dense graph

A few definitions first: Definition 1 A graph G = (V, E) is called ``dense'' if for each pair of non-adjacent vertices u and v, d(u) + d(v)>=n where n = |V| and d(*) denotes the degree of the vertex * Definition 2 A ``Hamiltonian cycle'' on G…
Traveling Salesman
  • 1,901
  • 8
  • 36
  • 66
1
vote
1 answer

Testing a Hamiltonian Path finder implementation

I am implementing an algorithm which finds an optimal Hamiltonian path in a directed graph. I have implemented an algorithm which appears to work reasonably well, however I am not entirely sure if there are subtle bugs or other issues in certain…
1
vote
1 answer

non-Hamilton path elimination in a graph

Assume that we have a random graph. How do you remove or add edges in the minimum number of steps such that every edge in the resulting graph would be in a Hamilton path? I would really appreciate if someone can share any ideas.
John
  • 11
  • 1