Presentation is loading. Please wait.

Presentation is loading. Please wait.

SULE SOLMAZ BEYZA AYTAR

Similar presentations


Presentation on theme: "SULE SOLMAZ BEYZA AYTAR"— Presentation transcript:

1 SULE SOLMAZ 140144053 BEYZA AYTAR 140144009
HAMILTONION PATH SULE SOLMAZ BEYZA AYTAR

2 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)

3

4

5 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.

6 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.

7 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

8 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

9 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! ).

10 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

11 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.

12 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.

13

14 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.

15 References pathhamiltonian-circuit/ traveling-salesman-problem/ and-hamiltonian-circuit/

16 THANK FOR LISTENING


Download ppt "SULE SOLMAZ BEYZA AYTAR"

Similar presentations


Ads by Google