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
4
votes
2 answers

Find Hamilton path in a polynomial time using oracle machine

Say you have an oracle that can determine (in a polynomial time) if there is a Hamilton path in a certain graph. (Reminder: the Hamilton path problem is in NPC). Describe how to use the oracle in order to find a Hamilton path in a graph, in a…
Shlomi Kriheli
  • 330
  • 1
  • 7
4
votes
1 answer

Finding a long vertex-disjoint cycle in a graph

I have a directed graph with 562 vertices and 3961 edges (the edges are http://a3nm.net/share/raw_graph_284374.txt if you are curious) and I would like to find a cycle in this graph which does not go twice through the same vertex and is as long as…
a3nm
  • 7,939
  • 5
  • 25
  • 39
3
votes
2 answers

ASP Hamiltonian Cycle Story

Hello I am new to answer-set-programming. I have done a little prolog in the past! I am trying to solve this problem I believe it can be solved with hamiltonian-cycle, let me know your opinion. If you are not familiar with ASP you can visit this…
3
votes
3 answers

Optimizing the function for finding a Hamiltionian cycle in a grid graph?

I've made a working algorithm for finding a Hamiltonian cycle in a grid graph. However, the approach I implemented includes recursively checking all the possible combinations until I find the right one. This is fine on small graphs (like 6*6), but…
yoda123
  • 45
  • 5
3
votes
2 answers

Finding the hamiltonian path in a directed cyclic graph

i want to know if there is an algorithm to find the longest cyclic path in a directed weighted graph (i think this i a problem of finding the largest Hamiltonian sub-graph). I need to start from one vertex and return to the same vertex, whit the…
Joksim
  • 59
  • 5
3
votes
1 answer

Hamiltonian path generator algorithm

I have been playing with Hamiltonian paths for some time and have found some cool uses of it. One being a sort of puzzle where the goal is to connect all the nodes to form a hamiltonian path. So, being a novice programmer I am, I created a very…
3
votes
0 answers

Study: NP-Completeness Using Hamiltonian Path

I'm preparing for exams and for my algorithms course we've been needing to cover NP completeness but we never had any real tutorials for them and just got given a pile of "practice questions" for the exam. I've worked through all but the last and…
Syzorr
  • 505
  • 1
  • 3
  • 14
3
votes
1 answer

Build all Hamiltonian paths from an edge list

I'm having trouble finding a way to build a tree path from a list of related tuples? I only want a list of every path where each node is visited once, aka hamiltonian path. I keep getting close but missing some path. For example, let's say we…
yekta
  • 3,133
  • 2
  • 32
  • 48
3
votes
1 answer

Unique Topological sorting implies hamiltonian path exists

In a DAG ,to find a hamiltonian path ,first topologocal sorting is found out and then hamiltonian path is found from the topological sort. Hamiltonian path in a DAG exists if and only if there is unique topological sorting. How do we justify this…
3
votes
1 answer

Find shortest path from X,Y coordinates (with start ≠ end)

I have a dataframe with X and Y coordinates of points like this: structure(list(X = c(666L, 779L, 176L, 272L, 232L, 74L, 928L, 667L, 1126L, 919L), Y = c(807, 518, 724, 221, 182, 807, 604, 384, 142, 728)), .Names = c("X", "Y"), row.names = c(NA,…
agenis
  • 6,725
  • 4
  • 34
  • 83
3
votes
2 answers

Fast Hamiltonian cycle calculation

Suppose that there is a directed graph consists of vertices named below: "ABC", "ABD", "ACB", "ACD", "ADB", "ADC", "BAC", "BAD", "BCA", "BCD", "BDA", "BDC", "CAB", "CAD", "CBA", "CBD", "CDA", "CDB", "DAB", "DAC", "DBA", "DBC", "DCA", "DCB" These…
Mehmet Fide
  • 1,534
  • 1
  • 17
  • 29
3
votes
1 answer

Finding all hamiltonian cycles

I'm trying to implement a method for adding all possible Hamiltonian cycles to a list using recursion. So far my stopping condition isn't sufficient and I get "OutOfMemoryError: Java heap space" in the line that adds a vertex to a list: private…
luke657
  • 809
  • 2
  • 11
  • 27
3
votes
2 answers

Palmer's Algorithm for Hamiltonian cycles

In a "dense" graph, I am trying to construct a Hamiltonian cycle using Palmer's Algorithm. However, I need more explanation for this algorithm because it does not work with me when I implement it. It seems that there is an unclear part in…
2
votes
4 answers

Hamiltonian paths & social graph algorithm

I have a random undirected social graph. I want to find a Hamiltonian path if possible. Or if not possible (or not possible to know if possible in polynomial time) a series of paths. In this "series of paths" (where all N nodes are used exactly…
lollercoaster
  • 13,421
  • 28
  • 94
  • 162
2
votes
3 answers

Reduction algorithm from the Hamiltonian cycle

I believe that the Hamiltonian cycle problem can be summed up as the following: Given an undirected graph G = (V, E), a Hamiltonian circuit is a tour in G passing through every vertex of G once and only once. Now, what I would like to do is…
Garrett
  • 10,560
  • 17
  • 74
  • 120