SULE SOLMAZ 140144053 BEYZA AYTAR 140144009 HAMILTONION PATH SULE SOLMAZ 140144053 BEYZA AYTAR 140144009
What is the Hamiltonian Path?? Hamiltonian Path also called a Hamilton path, in a directed or undirected graph is a graph path between two vertices of a graph that visit each vertex exactly once The problem to check whether a graph (directed or undirected) contains a Hamiltonian Path is NP-complete, so is the problem of finding all the Hamiltonian Paths in a graph. Hamiltonian Cycle: Hamiltonian path exists whose endpoints are adjacent, then the resulting graph cycle is called a Hamiltonian cycle . ( The circuit must return to the starting vertex)
A permutation of the vertices of the graph [v1, v2, v3, A permutation of the vertices of the graph [v1, v2, v3, ...... vN-1, vN] , such that there is an edge between vi and vi+1 where 1 ≤ i ≤ N-1. It can be checked for all permutations of the vertices whether any of them represents a Hamiltonian Path or not. Total 24 possible permutations, out of which only following represents a Hamiltonian Path in Fig. 2. which only following represents a Hamiltonian Path. 0-1-2-3 3-2-1-0 0-1-3-2 2-3-1-0
PROPERTIES OF HAMILTONION PATH Any hamiltonian cycle can be transformed into a hamiltonian path by removing a single edge. For strongly connected graphs, the number of different hamiltonian path is (n-1)!/2.
Usage Areas of Hamiltonian path Many graphs can be used to solve the theory problem such as the travelling salesman problem. They can be used in data security (cryptography) problems such as zero-knowledge proof. Gray codes
Following is the pseudo code of the algorithm: function check_all_permutations(adj[][], n) for i = 0 to n p[i]=i while next permutation is possible valid = true for i = 0 to n-1 if adj[p[i]][p[i+1]] == false valid = false break if valid == true return true p = get_next_permutation(p) return false
COMPLEXITY Time complexity of the method can be easily derived on the previous slide. For a graph having N vertices it visits all the permutations of the vertices, N! iterations and in each of those iterations it traverses the permutation to see if adjacent vertices are connected or not N iterations, so the complexity is O( N * N! ).
Travelling Salesman Nearest Neighbor Algorithm: Starting from the “home” city(or vertex),first visit the nearest city (one with the least mileage from “home”),that has not already been visited. When all other vertices have been visited,the tour returns home. Hamiltonian Circuit: Hamiltonian Circuit: A-B-C-E-D-A B-C-A-D-E-B Nearest neighbor starting at vertex A Nearest neighbor starting at vertex B
The problem here: We have a weighted graph, and want to find the circuit with the lowest weight. The usual explanation: a salesman has to visit all of his clients and wants to make the journey with the least time/distance/fuel. We use the value we're trying to minimize as the edge weight.
1. Greedy approach: According to this approach, any city is selected as the starting city after that s the nearest city is selected and added to the list. In this way all the cities are added to the list until the last city added .We will always selected as the nearest city. 2. Smallest increase method: In this method, the total distance is recalculated every time, and if any of the alternatives is added, the total distance traveled is minimized and new cities are added.
Gray Code Animation Here we show a Hamiltonian cycle on a 5-dimensional hypercube. Note that it starts by completely traversing the 4- dimensional hypercube on the left before reversing the traversal on the right subcube. Hamiltonian cycles on hypercubes provide constructions for Gray codes, namely orderings of all subsets of n items such that neighboring subsets differ in exactly one element. Hamilitonian cycle is an NP-complete problem, so no worst-case efficient algorithm exists to find such a cycle.
References http://www3.cs.stonybrook.edu/~algorith/files/hamiltonian-cycle.shtml http://slideplayer.com/slide/7805935/ https://www.cs.sfu.ca/~ggbaker/zju/math/euler-ham.html#ham http://bilgisayarkavramlari.sadievrenseker.com/2009/06/17/hamilton-yolu-hamiltonian- pathhamiltonian-circuit/ http://bilgisayarkavramlari.sadievrenseker.com/2008/08/28/seyyar-tuccar-problemi- traveling-salesman-problem/ http://www.ensarkarabudak.com/muhendislik/hamilton-yolu-devresihamiltonian-path- and-hamiltonian-circuit/ http://www.geeksforgeeks.org/travelling-salesman-problem-set-1/ http://www3.cs.stonybrook.edu/~skiena/combinatorica/animations/ham.html
THANK FOR LISTENING