PATH FINDING AND GRAPH TRAVERSAL

Similar documents
Chapter 9 Graph Algorithms

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

IE 102 Spring Routing Through Networks - 1

Chapter 14 Section 3 - Slide 1

(Refer Slide Time: 01:00)

EECS 203 Lecture 20. More Graphs

Undirected Network Summary

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms

11.2 Eulerian Trails

Introduction to Graphs

The Shortest Path Problem

Precept 4: Traveling Salesman Problem, Hierarchical Clustering. Qian Zhu 2/23/2011

Topics Covered. Introduction to Graphs Euler s Theorem Hamiltonian Circuits The Traveling Salesman Problem Trees and Kruskal s Algorithm

Graphs and Algorithms

4.1.2 Merge Sort Sorting Lower Bound Counting Sort Sorting in Practice Solving Problems by Sorting...

CS350: Data Structures Dijkstra s Shortest Path Alg.

Unweighted Graphs & Algorithms

Crossing bridges. Crossing bridges Great Ideas in Theoretical Computer Science. Lecture 12: Graphs I: The Basics. Königsberg (Prussia)

Eulerian Paths and Cycles

Homework 5: Graphs, Minimum Spanning Trees, and Dijkstra Shortest-Path

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

Graph Algorithms. A Brief Introduction. 高晓沨 (Xiaofeng Gao) Department of Computer Science Shanghai Jiao Tong Univ.

CSE 417 Branch & Bound (pt 4) Branch & Bound

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Ma/CS 6a Class 8: Eulerian Cycles

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics

Topic 10 Part 2 [474 marks]

Module 6 NP-Complete Problems and Heuristics

8.2 Paths and Cycles

Discrete Mathematics for CS Spring 2008 David Wagner Note 13. An Introduction to Graphs

Algorithm Design (8) Graph Algorithms 1/2

SEVENTH EDITION and EXPANDED SEVENTH EDITION

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms

Lecture 3: Graphs and flows

Reference Sheet for CO142.2 Discrete Mathematics II

Traveling Salesman Problem (TSP) Input: undirected graph G=(V,E), c: E R + Goal: find a tour (Hamiltonian cycle) of minimum cost

Chapter 8 Topics in Graph Theory

3 Euler Tours, Hamilton Cycles, and Their Applications

Module 2: NETWORKS AND DECISION MATHEMATICS

6.2. Paths and Cycles

V1.0: Seth Gilbert, V1.1: Steven Halim August 30, Abstract. d(e), and we assume that the distance function is non-negative (i.e., d(x, y) 0).

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Jörgen Bang-Jensen and Gregory Gutin. Digraphs. Theory, Algorithms and Applications. Springer

Introduction to Graph Theory

Understand graph terminology Implement graphs using

Math 443/543 Graph Theory Notes 2: Transportation problems

Questions? You are given the complete graph of Facebook. What questions would you ask? (What questions could we hope to answer?)

Coping with the Limitations of Algorithm Power Exact Solution Strategies Backtracking Backtracking : A Scenario

A path that visits every vertex exactly once is a Hamiltonian path. A circuit that visits every vertex exactly once is a Hamiltonian circuit.

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Solving problems on graph algorithms

14 More Graphs: Euler Tours and Hamilton Cycles

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. An Introduction to Graph Theory

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Study Guide Mods: Date:

Topics for today. Basics of combinatorial counting Applications to running time analysis

Polynomial time approximation algorithms

CS161 - Final Exam Computer Science Department, Stanford University August 16, 2008

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Search Algorithms. IE 496 Lecture 17

Warm -Up. 1. Draw a connected graph with 4 vertices and 7 edges. What is the sum of the degrees of all the vertices?

CSE 100 Minimum Spanning Trees Prim s and Kruskal

1. Sorting (assuming sorting into ascending order) a) BUBBLE SORT

DESIGN AND ANALYSIS OF ALGORITHMS

Graph and Digraph Glossary

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 8

INF280 Graph Traversals & Paths

CSCE 350: Chin-Tser Huang. University of South Carolina

CSE 100: B+ TREE, 2-3 TREE, NP- COMPLETNESS

The Shortest Path Problem. The Shortest Path Problem. Mathematical Model. Integer Programming Formulation

Today s Outline. CSE 326: Data Structures. Topic #15: Cool Graphs n Pretty Pictures. A Great Mathematician. The Bridges of Königsberg

Approximation Algorithms

PSD1A. DESIGN AND ANALYSIS OF ALGORITHMS Unit : I-V

DS UNIT 4. Matoshri College of Engineering and Research Center Nasik Department of Computer Engineering Discrete Structutre UNIT - IV

PATH FINDING AND GRAPH TRAVERSAL

Lecture 10 Graph Algorithms

CS270 Combinatorial Algorithms & Data Structures Spring Lecture 19:

Graph Theory: Starting Out

Minimum Spanning Tree

Konigsberg Bridge Problem

Analysis of Algorithms

Dynamic programming. Trivial problems are solved first More complex solutions are composed from the simpler solutions already computed

Theorem 2.9: nearest addition algorithm

Introduction to Approximation Algorithms

Varying Applications (examples)

Simple Graph. General Graph

Chapter 3: Paths and Cycles

Graphs and trees come up everywhere. We can view the internet as a graph (in many ways) Web search views web pages as a graph

Graph Theory. Connectivity, Coloring, Matching. Arjun Suresh 1. 1 GATE Overflow

Practice Final Exam 1

Dijkstra's algorithm Prim's algorithm

Chapter-6 Backtracking

2. True or false: even though BFS and DFS have the same space complexity, they do not always have the same worst case asymptotic time complexity.

MITOCW watch?v=zm5mw5nkzjg

WUCT121. Discrete Mathematics. Graphs

Transcription:

GRAPH TRAVERSAL

PATH FINDING AND GRAPH TRAVERSAL Path finding refers to determining the shortest path between two vertices in a graph. We discussed the Floyd Warshall algorithm previously, but you may achieve similar results with the Dijkstra or Bellman-Ford algorithms. Graph traversal refers to the problem of visiting a set of nodes in a graph in a certain way. You can use depth- or breadth-first search algorithms to traverse an entire graph starting from a given "root" (source vertex).

PATH FINDING AND GRAPH TRAVERSAL Today we will discuss some heuristics for finding circuits (tours) on graphs. We are particularly interested in finding circuits that also have minimum cost. Remember that circuits can include the same vertex twice, but arcs only once. You may want to perform some pre-processing on the graph to handle such restrictions.

TERMINOLOGY: HAMILTONIAN CIRCUIT A Hamiltonian circuit is a path that visits every vertex exactly once and starts at ends at the same vertex NB: Not all graphs may have a Hamiltonian circuit

MINIMUM COST HAMILTONIAN CIRCUIT In a weighted graph, the minimum cost Hamiltonian circuit is that where the sum of the arc weights is the smallest. Finding the minimum cost Hamiltonian circuit on your bin service graphs is one option for route planning. Finding a Hamiltonian circuit can be difficult. This is a known NP complete problem. Simply put, the problem may not be solvable in polynomial time and the complexity increases with the number of vertices.

HEURISTIC ALGORITHMS Heuristics work quite well for finding (no always optimal, but good) solutions, most of the time. Work relatively fast. Popular heuristics for finding minimum cost Hamiltonian circuits: Nearest Neighbour Algorithm Sorted Edges Algorithm

NEAREST NEIGHBOUR ALGORITHM Nearest Neighbour is a greedy algorithm at every step it chooses as the next vertex the one connected to the current through the arc with the smallest weight. Only searches locally. Nodes already visited are ignored. Due to its greedy nature it may not find a solution. Finding a solution and its total cost depends on the start vertex chosen.

EXAMPLE, STARTING AT '3'

EXAMPLE, STARTING AT '3' (NO SOLUTION)

EXAMPLE, STARTING AT '5'

EXAMPLE, STARTING AT '5' (CONT'D)

SORTED EDGES ALGORITHM Also greedy, but has a more global view takes slightly more time to find a solution. First sorts all the (directed) edges in ascending order of their weights. Adds sorted edges one at the time, unless adding a new one leads to three arcs entering/leaving a node, or creates a circuit that does not include all vertices. Skips the arcs that violate these rules. Keeps adding arcs until finding a Hamiltonian circuit (or no more arcs left). Stops when a solution is found, even if there are arcs left.

EXAMPLE

EXAMPLE (CONT'D)

EXAMPLE (CONT'D)

No solution found.

BRUTE FORCE ALGORITHM When the number of vertices is small, a 'brute force' approach could be feasible. Find all paths that visit all vertices once and pick the one with the lowest cost. Guaranteed to find a solution (if there exists one), and this will be optimal.

OTHER APPROACHES A Hamiltonian circuit may not always be the path that visits all the vertices and has the lowest cost. Sometimes visiting a node more than once can give circuits that are more cost effective. The problem could also be seen as an instance of finding an Eulerian circuit (cycle).

EULERIAN CIRCUITS An Eulerian path visits every edge (arc) exactly once. The idea dates back to birth of Graph Theory, when Leonhard Euler was asked to determine a path that traverses all of the 7 bridges in Koenigsberg exactly once. Source: Nature Biotechnology

EULERIAN CIRCUITS An Eulerian circuit begins and ends at the same vertex. Euler realised a solution to the original problem did not exist, but found conditions that a graph must fulfil to have Eulerian paths. For your problem (directed graphs), it is important to know Eulerian circuits exist if and only if every vertex has equal in degree and out degree.

EXAMPLES Total cost: 28

HIERHOLZER'S ALGORITHM Assuming you have verified the necessary condition the graph must meet to have an Eulerian circuit. Pick any vertex as a starting point. Add arcs to build trail, until returning to the start. You cannot get stuck at other vertices. If there are vertices on this tour but have adjacent arcs not included, start new trail from these. Join the tours formed this way.

EXAMPLE

THE PROBLEM YOU ARE TRYING TO SOLVE The graphs you will be given may not have Hamiltonian or Eulerian circuits. Even if they do, at start of service in an area you may not need to visit ALL the bins (vertices). It is likely you will need to do some pre-processing, e.g. Build complete graphs starting from the original ones. Remove some arcs. And work only with a subset of vertices (the bins that require service).

THE PROBLEM YOU ARE TRYING TO SOLVE There is no BEST solution. Depending on the graph structure/size, some may return more cost effective circuits than others. But may also take more time. Try to experiment with several, but aim to have at least ONE decent implementation.