0200 Hamiltonian Circuits Review Day Hamiltonian Circuits 3

  • Slides: 16
Download presentation
0200 Hamiltonian Circuits Review Day

0200 Hamiltonian Circuits Review Day

Hamiltonian Circuits 3 Rules: v Start and stop at the same vertex v Touch

Hamiltonian Circuits 3 Rules: v Start and stop at the same vertex v Touch every vertex v Pass through every vertex only once Example:

22 27

22 27

Fundamental principle of counting: If there a ways of choosing on thing, b ways

Fundamental principle of counting: If there a ways of choosing on thing, b ways of choosing a second after the first is chosen, … and z ways of choosing the last item after the earlier choices, then the total number of choice patterns is: a X b X c X …. X z 19

FPC for Hamiltonian Circuits: Given a complete graph with n vertices, once you choose

FPC for Hamiltonian Circuits: Given a complete graph with n vertices, once you choose the beginning vertex, there are n-1 ways to choose the second vertex, the next will have n-2 ways to be chosen, and so on. . . So a complete Hamiltonian Circuit will have (n-1)! POSSIBLE routes. Since a route is the same forwards and backwards, there are (n-1)!/2 DIFFERENT routes. 5. . .

The Traveling Salesman Problem adds “weights” based on the context of the problem to

The Traveling Salesman Problem adds “weights” based on the context of the problem to each of the edges. To solve this problem and find a “minimum-cost circuit” we can use one of three different methods: v. Brute force method: will give ALL possible routes, therefore ALWAYS finding the absolute minimum-cost circuit v. Nearest-neighbor algorithm: will give A minimum-cost circuit, but maybe NOT the absolute smallest and may depend on the starting vertex v. Sorted-edges algorithm: will give A minimum-cost circuit, but maybe NOT the absolute smallest OR the same as the nearest-neighbor

Brute Force Method: 1. 2. 3. 24 Find all possible routes using the method

Brute Force Method: 1. 2. 3. 24 Find all possible routes using the method of trees Calculate all the routes’ costs Pick the smallest number

Nearest-neighbor algorithm: In the context that the vertices are cities 1. You will be

Nearest-neighbor algorithm: In the context that the vertices are cities 1. You will be given a starting city (if not must calculate starting at every city) 2. Visit the “nearest” city 3. Visit the “nearest” city that has not already been visited 4. Repeat step 3 over and over - Return to the starting city only once all the cities have been visited 5. Tally the weights of the edges used 4. . .

Sorted-edges Algorithm: Not dependent on a starting vertex 1. 2. 3. 4. 5. Remove

Sorted-edges Algorithm: Not dependent on a starting vertex 1. 2. 3. 4. 5. Remove all the edges Sort the edges from smallest to largest Place the smallest edge back on the graph Place the next smallest edge back on the graph Place third smallest edge and so on until a HC is created - Skip edges that create a circuit on the graph that doesn’t include all the vertices - Skip edges that make the valence of a vertex more than 2 6. Tally the weights of the edges used 20

A Hamiltonian Circuit must use EVERY vertex on a given graph A Spanning Tree

A Hamiltonian Circuit must use EVERY vertex on a given graph A Spanning Tree must also use EVERY vertex on a graph, BUT in a spanning tree closing the circuit is not necessary and it’s perfectly ok to retrace your steps 18

Kruskal’s Algorithm: only algorithm we know to find a minimum-cost spanning tree 1. 2.

Kruskal’s Algorithm: only algorithm we know to find a minimum-cost spanning tree 1. 2. 3. 4. 5. 6. Remove all the edges Sort the edges from smallest to largest Place the smallest edge on the graph Place the second smallest edge on the graph Continue placing edges on the graph until the graph is connected (Can I trace my pencil over the entire graph without lifting my pencil? ) Locate any circuits and remove the largest edge 21

13 Can you give an example why we would use a spanning tree and

13 Can you give an example why we would use a spanning tree and not a Hamiltonian Circuit?

Order-requirement digraph: the longest path is the shortest possible completion time, known as the

Order-requirement digraph: the longest path is the shortest possible completion time, known as the critical path 26 9. . .

#64 from book At a large toy store, scooters arrive unassembled in boxes. To

#64 from book At a large toy store, scooters arrive unassembled in boxes. To assemble a scooter, the following tasks must be performed: TASK 1: Remove parts from the box TASK 2: Attach wheels to the footboard TASK 3: Attach vertical housing TASK 4: Attach handlebars to vertical housing TASK 5: Put on reflector tape TASK 6: Attach bell to handlebars TASK 7: Attach decals TASK 8: Attach kickstand TASK 9: Attach safety instructions to handlebars It’s like a puzzle!!

HAPPY STUDYING!!!

HAPPY STUDYING!!!