L3 Network Algorithms

Size: px
Start display at page:

Download "L3 Network Algorithms"

Transcription

1 L3 Network Algorithms NGEN06(TEK230) Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov by Abdulghani Hasan, Nov 2017 by Per-Ola Olsson

2 Content 1. General issues of networks 2. Shortest path - Dijkstra s algorithm 3. Other shortest path algorithms 4. Neighbourhood graphs and clustering 5. Traveling salesman problem.

3 Networks in GIS By using the distances between nodes in a network we can e.g. derive the shortest path, minimum number of nodes to pass and study accessibility.

4 What is a network A network or graph has 2 main constitutes: Nodes Edges Edges give distances between nodes. Distances can e.g. be: - Euclidean distances - Travelling time The network can e.g. be: - street network - airplane routes

5 What is a network A network or graph has 2 main constitutes: Nodes Edges Many analysis in networks only consider the nodes and the edges. Geometric location of the nodes is uninteresting

6 General issues of networks Networks can be stored in matrixes. Not a good data storage, especially for sparse networks, since it requires a lot of memory. But a matrix gives fast access to the nodes; O(1) to access a single node. For example fast to check if two nodes are connected. In most cases relational databases or lists and trees are more suitable storage structures. A B C D A B C D implies that the nodes are not connected by any edge

7 Graphic Representation (easy for humans To read) Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004

8 Sparse network with several zeros stored Graphic representation Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004

9 a connected to: b, distance 20 and g, distance 15 Graphic representation Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004

10 Compare to matrix with one row h connected to c, distance 10 Graphic representation Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004

11 Shortest path The path between two nodes that is shorter than all other possible paths. In the shortest path problem we are not only restricted to Euclidean distances, but all the kind of distances are of interest.

12 Navigation Start point target point (distance c -> a is 28) Accessibility Many points target point Shortest path

13 Navigation Start point target point Shortest path Accessibility Many points target point (access e from four points - c,d,f,g)

14 Shortest path Accessibility to parks and nature in Gothenburg (Viktor Svanerud, master thesis)

15 Dijkstra s algorithm - one of the most well-known shortest path algorithms. Example of finding the shortest path between Node A and Node D. We need 2 matrixes: Adjacency matrix (static) State matrix (dynamic) A B C D A B C D We recognise the adjacency matrix from above

16 Dijkstra s algorithm Example of finding the shortest path between Node A and Node D. We need 2 matrixes: Adjacency matrix (static) State matrix (dynamic) Node Distance Path Visited A 0 - Yes B 2 A No C 1 A No D - No Distance a -> b is 2 The state matrix is dynamic and changes when a node is visited.

17 Dijkstra s algorithm State matrix: Node is the ID of the nodes. Distance keeps track of the current shortest distance from the starting node to this node. Path stores the previous node along the shortest path (found so far) to this node. Visited states if the node has been visited in the computations of the shortest path (explained later). Node Distance Path Visited A 0 - Yes B 2 A No C 1 A No D - No Start point is A

18 Dijkstra s algorithm First initialize the state matrix: The start node is marked as visited. All nodes that can be reached from the start are updated in the columns distance and path based on Adjacency matrix (row-wise). Distance values are set to the distances between the start node and the respective node (derived from the adjacency matrix). Path values are set to the start node (the starting node is the current shortest path to this particular node) If there is no path to a node, the distance is set to infinity and the path value is undefined. Node Distance Path Visited A 0 - Yes B 2 A No C 1 A No D - No The state matrix is initialized for start point A

19 Dijkstra s algorithm After the state matrix is initialized: 1. Find the node with the shortest distance that is not yet visited. Denote this as the current node. 2. Mark the current node as visited. 3. For each node (m) that is not yet visited do: If the node m and the current node has a common edge AND if the sum of the distance from the start node to the current node and the distance from the current node to the node m (found in the adjacency matrix) is shorter than the current distance from the starting node to node m (stored in the state matrix) DO State matrix update the distance and the path for node m. 4. Proceed from (1) again until the end node is visited.

20 1. Find the node with the shortest distance that is not yet visited. Denote this as the current node. 2. Mark the current node as visited. 3. For each node (m) that is not yet visited do: If the node m and the current node has a common edge AND if the sum of the distance from the start node to the current node and the distance from the current node to the node m (found in the adjacency matrix) is shorter than the current distance from the starting node to node m (stored in the state matrix) DO update the distance and the path for node m. 4. Proceed from (1) again until the end node is visited. Adjacency matrix A B C D Adjacency matrix: If nodes have a common edge and for distances between current node and node m A B C D

21 Result of the shortest path algorithm Distance from start to end node (Distance) Path? Node Distance Path Visited A 0 - Yes B 2 A Yes C 1 A Yes D 4 B Yes

22 Result of the shortest path algorithm Distance from start to end node (Distance) Path from end backwards to start. Node Distance Path Visited A 0 - Yes B 2 A Yes C 1 A Yes D 4 B Yes

23 Does Dijkstra s algorithm always give a correct answer? Yes, no heuristics are involved BUT all types of distances are not allowed. L3-Network Algorithms Conditions for a metric: 1. d(p,q)>=0, d(p,q)=0 p=q 2. d(p,q)=d(q,p) (symmetry) 3. d(p,q)<=d(p,r)+d(r,q) (triangle inequality) Preparation for the network algorithm exercise.

24 What s the computational complexity of Dijkstra s algorithm? 1. Find the node with the shortest distance and that is not yet visited. 2. Mark the current node as visited. For each node (m) that is not yet visited do: 4. Proceed from (1) again until the end node is visited.

25 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and b to V 3. Add a (first in Q) to visited and add nodes connected to a LAST in Q. 4. Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited and add nodes connected to d LAST in Q

26 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and b to V 3. Add a (first in Q) to visited and add nodes connected to a LAST in Q. 4. Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited and add nodes connected to d LAST in Q

27 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and b to V 3. Add a (first in Q) to visited and add nodes connected to a LAST in Q. 4. Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited and add nodes connected to d LAST in Q

28 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and b to V 3. Add a (first in Q) to visited and add nodes connected to a LAST in Q. 4. Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited. No new nodes connected to d

29 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited. No new nodes connected to d. 6. Add g (first in Q) to visited. No new nodes connected to g.

30 Breadth-first traversal Q is a queu property is first-in-first-out b is the starting point Source: Worboys and Duckham Add c (first in Q) to visited and add nodes connected to c LAST in Q. 5. Add d (first in Q) to visited. No new nodes connected to d. 6. Add g (first in Q) to visited. No new nodes connected to g. 7. Add e (first in Q) to visited and add nodes connected to e LAST in Q. 8.

31 Depth-first traversal Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add c (first in Q) to visited and add nodes connected to c FIRST in Q. 5. Add d (first in Q) to visited and add nodes connected to d FIRST in Q

32 Depth-first traversal Now g is added FIRST Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add c (first in Q) to visited and add nodes connected to c FIRST in Q. 5. Add d (first in Q) to visited and add nodes connected to d FIRST in Q

33 Depth-first traversal Now we follow the path a -> g deeper and add e FIRST in Q Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add g (first in Q) to visited and add nodes connected to g FIRST in Q. 5. Add d (first in Q) to visited and add nodes connected to d FIRST in Q

34 Depth-first traversal Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add g (first in Q) to visited and add nodes connected to g FIRST in Q. 5. Add e (first in Q) to visited and add nodes connected to e FIRST in Q

35 Depth-first traversal Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add g (first in Q) to visited and add nodes connected to g FIRST in Q. 5. Add e (first in Q) to visited and add nodes connected to e FIRST in Q. 6. Add f (first in Q) to visited. No new nodes connected to f.

36 1. Start point b 2. Add nodes connected to b to Q and add b to V 3. Add a (first in Q) to visited and add nodes connected to a FIRST in Q. 4. Add g (first in Q) to visited and add nodes connected to g FIRST in Q. 5. Add e (first in Q) to visited and add nodes connected to e FIRST in Q. 6. Add f (first in Q) to visited. No new nodes connected to f. 7. Add c (first in Q) to visited and add nodes connected to c FIRST in Q. L3-Network Algorithms Depth-first traversal Q is a stack property is last-in-first-out b is the starting point Source: Worboys and Duckham 2004

37 Breadth-first, depth-first traversal L3-Network Algorithms

38 Dijkstra s algorithm Breadth-first or Depth-first algorithm?

39 Dijkstra s algorithm - breadth first algorithm Dijkstra s algorithm search in all directions for the shortest path. It is an breadth-first algorithm

40 Other shortest path algorithms Algorithms with heuristics do not always give the best answer (only a reasonably good answer is guaranteed). Heuristic 1 Direction limitation (nodes closer to the end node) A* algorithm Euclidean distances, depth-first & breadth-first More likely that the shortest path is towards the end node

41 Other shortest path algorithms Algorithms with heuristics do not always give the best answer (only a reasonably good answer is guaranteed). Heuristic 2 Hierarchical algorithm Minor roads and major roads Minor roads only the last and first part of the route. Major roads (highways) for the main part of the route.

42 Other shortest path algorithms Algorithms with heuristics do not always give the best answer (only a reasonably good answer is guaranteed). Heuristic 3 super nodes (transit nodes) Stored distances between super nodes (transit nodes)

43 Neighbourhood graphs minimum spanning tree (MST) Minimum Spanning Tree (MST) 1. No isolated node 2.

44 Kruskal s algorithm for computing MST L3-Network Algorithms Original Edges Ordered Sort the edges in ascending order after distance. While there are isolated nodes in the ordered list add the currently shortest node to the MST. Do NOT add nodes that create a closed circle Source: Sedgewick 2002

45 Neighbourhood graphs and Clustering Visually easy to identify clusters, but how to compute?

46 Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1. No isolated node Threshold distance 2.

47 Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1. No isolated node Threshold distance 2.

48 Traveling salesman problem (TSP) 1. Begin and end in the same node (or in different nodes) 2. Visit all nodes. 3. Minimize total length of the route.

49 Traveling salesman problem (TSP) How to solve the TSP problems? To compute all possible combinations and chose the shortest one is too computational demanding. It is NP-complete Use the minimum spanning tree: The maximum length of the TSP is at most 2 times the total length of the MST

50 Traveling salesman problem (TSP) How to solve the TSP problems? Compute the MST e.g. with Kruskal s algorithm. Do iterative improvements until no further improvements are possible. A local optimum of the TSP is found.

L1-Spatial Concepts L1 - Spatial Concepts

L1-Spatial Concepts L1 - Spatial Concepts L1 - Spatial Concepts NGEN06(TEK230) Algorithms in Geographical Information Systems Aim Understand the relationship between spatial queries and mathematical concepts. Know how topological relationships

More information

CSS 343 Data Structures, Algorithms, and Discrete Math II. Graphs II. Yusuf Pisan

CSS 343 Data Structures, Algorithms, and Discrete Math II. Graphs II. Yusuf Pisan CSS 343 Data Structures, Algorithms, and Discrete Math II Graphs II Yusuf Pisan 2 3 Shortest Path: Dijkstra's Algorithm Shortest path from given vertex to all other vertices Initial weight is first row

More information

Design and Analysis of Algorithms

Design and Analysis of Algorithms CSE 101, Winter 2018 Design and Analysis of Algorithms Lecture 9: Minimum Spanning Trees Class URL: http://vlsicad.ucsd.edu/courses/cse101-w18/ Goal: MST cut and cycle properties Prim, Kruskal greedy algorithms

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures 3 Definitions an undirected graph G = (V, E) is a

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Introduction graph theory useful in practice represent many real-life problems can be if not careful with data structures Chapter 9 Graph s 2 Definitions Definitions an undirected graph is a finite set

More information

SPANNING TREES. Lecture 21 CS2110 Spring 2016

SPANNING TREES. Lecture 21 CS2110 Spring 2016 1 SPANNING TREES Lecture 1 CS110 Spring 016 Spanning trees What we do today: Calculating the shortest path in Dijkstra s algorithm Look at time complexity of shortest path Definitions Minimum spanning

More information

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017

CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017 CMSC 451: Lecture 22 Approximation Algorithms: Vertex Cover and TSP Tuesday, Dec 5, 2017 Reading: Section 9.2 of DPV. Section 11.3 of KT presents a different approximation algorithm for Vertex Cover. Coping

More information

Graphs Introduction and Depth first algorithm

Graphs Introduction and Depth first algorithm Graphs Introduction and Depth first algorithm Carol Zander Introduction to graphs Graphs are extremely common in computer science applications because graphs are common in the physical world. Everywhere

More information

ECE 242 HOMEWORK 5. In the figure below, one can go from node B to A but not from A to B.

ECE 242 HOMEWORK 5. In the figure below, one can go from node B to A but not from A to B. ECE 242 HOMEWORK 5 Question 1: Define the following terms. For lines with multiple terms,differentiate between the terms. Also draw a figure illustrating each term. (a) Directed graph and undirected graph

More information

2 Approximation Algorithms for Metric TSP

2 Approximation Algorithms for Metric TSP Comp260: Advanced Algorithms Tufts University, Spring 2002 Professor Lenore Cowen Scribe: Stephanie Tauber Lecture 3: The Travelling Salesman Problem (TSP) 1 Introduction A salesman wishes to visit every

More information

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees //8 About A, Prelim Spanning Trees, greedy algorithms Lecture CS Fall 8 Prelim : Thursday, November. Visit exams page of course website and read carefully to find out when you take it (: or 7:) and what

More information

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018 1 Spanning Trees, greedy algorithms Lecture 20 CS2110 Fall 2018 1 About A6, Prelim 2 Prelim 2: Thursday, 15 November. Visit exams page of course website and read carefully to find out when you take it

More information

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms Chapter 9 Graph Algorithms 2 Introduction graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 3 Definitions an undirected graph G = (V, E)

More information

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017

Spanning Trees, greedy algorithms. Lecture 22 CS2110 Fall 2017 1 Spanning Trees, greedy algorithms Lecture 22 CS2110 Fall 2017 1 We demo A8 Your space ship is on earth, and you hear a distress signal from a distance Planet X. Your job: 1. Rescue stage: Fly your ship

More information

(Refer Slide Time: 01:00)

(Refer Slide Time: 01:00) Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras Lecture minus 26 Heuristics for TSP In this lecture, we continue our discussion

More information

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

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions Introduction Chapter 9 Graph Algorithms graph theory useful in practice represent many real-life problems can be slow if not careful with data structures 2 Definitions an undirected graph G = (V, E) is

More information

Algorithm Design (8) Graph Algorithms 1/2

Algorithm Design (8) Graph Algorithms 1/2 Graph Algorithm Design (8) Graph Algorithms / Graph:, : A finite set of vertices (or nodes) : A finite set of edges (or arcs or branches) each of which connect two vertices Takashi Chikayama School of

More information

Constrained Minimum Spanning Tree Algorithms

Constrained Minimum Spanning Tree Algorithms December 8, 008 Introduction Graphs and MSTs revisited Minimum Spanning Tree Algorithms Algorithm of Kruskal Algorithm of Prim Constrained Minimum Spanning Trees Bounded Diameter Minimum Spanning Trees

More information

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved. Chapter 9 Greedy Technique Copyright 2007 Pearson Addison-Wesley. All rights reserved. Greedy Technique Constructs a solution to an optimization problem piece by piece through a sequence of choices that

More information

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2. Problem Solving Agents. Problem Solving Agents: Assumptions

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2. Problem Solving Agents. Problem Solving Agents: Assumptions Class Overview COMP 3501 / COMP 4704-4 Lecture 2 Prof. JGH 318 Problem Solving Agents Problem Solving Agents: Assumptions Requires a goal Assume world is: Requires actions Observable What actions? Discrete

More information

val(y, I) α (9.0.2) α (9.0.3)

val(y, I) α (9.0.2) α (9.0.3) CS787: Advanced Algorithms Lecture 9: Approximation Algorithms In this lecture we will discuss some NP-complete optimization problems and give algorithms for solving them that produce a nearly optimal,

More information

1 Variations of the Traveling Salesman Problem

1 Variations of the Traveling Salesman Problem Stanford University CS26: Optimization Handout 3 Luca Trevisan January, 20 Lecture 3 In which we prove the equivalence of three versions of the Traveling Salesman Problem, we provide a 2-approximate algorithm,

More information

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck Theory of Computing Lecture 10 MAS 714 Hartmut Klauck Seven Bridges of Königsberg Can one take a walk that crosses each bridge exactly once? Seven Bridges of Königsberg Model as a graph Is there a path

More information

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each

Multiple Choice. Write your answer to the LEFT of each problem. 3 points each CSE 0-00 Test Spring 0 Name Last 4 Digits of Student ID # Multiple Choice. Write your answer to the LEFT of each problem. points each. Suppose f ( x) is a monotonically increasing function. Which of the

More information

PBW 654 Applied Statistics - I Urban Operations Research. Unit 3. Network Modelling

PBW 654 Applied Statistics - I Urban Operations Research. Unit 3. Network Modelling PBW 54 Applied Statistics - I Urban Operations Research Unit 3 Network Modelling Background So far, we treated urban space as a continuum, where an entity could travel from any point to any other point

More information

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

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1 Chapter 14 Graphs 2011 Pearson Addison-Wesley. All rights reserved 14 A-1 Terminology G = {V, E} A graph G consists of two sets A set V of vertices, or nodes A set E of edges A subgraph Consists of a subset

More information

Traveling Salesperson Problem (TSP)

Traveling Salesperson Problem (TSP) TSP-0 Traveling Salesperson Problem (TSP) Input: Undirected edge weighted complete graph G = (V, E, W ), where W : e R +. Tour: Find a path that starts at vertex 1, visits every vertex exactly once, and

More information

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees /9/7 Prelim, assignments Prelim is Tuesday. See the course webpage for details. Scope: up to but not including today s lecture. See the review guide for details. Deadline for submitting conflicts has passed.

More information

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 97 E-mail: natarajan.meghanathan@jsums.edu Optimization vs. Decision

More information

Spanning Trees. Lecture 22 CS2110 Spring 2017

Spanning Trees. Lecture 22 CS2110 Spring 2017 1 Spanning Trees Lecture 22 CS2110 Spring 2017 1 Prelim 2, assignments Prelim 2 is Tuesday. See the course webpage for details. Scope: up to but not including today s lecture. See the review guide for

More information

Introduction to Parallel & Distributed Computing Parallel Graph Algorithms

Introduction to Parallel & Distributed Computing Parallel Graph Algorithms Introduction to Parallel & Distributed Computing Parallel Graph Algorithms Lecture 16, Spring 2014 Instructor: 罗国杰 gluo@pku.edu.cn In This Lecture Parallel formulations of some important and fundamental

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu P, NP-Problems Class

More information

Analysis of Algorithms

Analysis of Algorithms Second Edition Design and Analysis of Algorithms Prabhakar Gupta Vineet Agarwal Manish Varshney Design and Analysis of ALGORITHMS SECOND EDITION PRABHAKAR GUPTA Professor, Computer Science and Engineering

More information

Module 6 NP-Complete Problems and Heuristics

Module 6 NP-Complete Problems and Heuristics Module 6 NP-Complete Problems and Heuristics Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 397 E-mail: natarajan.meghanathan@jsums.edu Optimization vs. Decision

More information

Outline. Graphs. Divide and Conquer.

Outline. Graphs. Divide and Conquer. GRAPHS COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges books. Outline Graphs.

More information

1 The Traveling Salesman Problem

1 The Traveling Salesman Problem Comp 260: Advanced Algorithms Tufts University, Spring 2011 Prof. Lenore Cowen Scribe: Jisoo Park Lecture 3: The Traveling Salesman Problem 1 The Traveling Salesman Problem The Traveling Salesman Problem

More information

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

Precept 4: Traveling Salesman Problem, Hierarchical Clustering. Qian Zhu 2/23/2011 Precept 4: Traveling Salesman Problem, Hierarchical Clustering Qian Zhu 2/23/2011 Agenda Assignment: Traveling salesman problem Hierarchical clustering Example Comparisons with K-means TSP TSP: Given the

More information

1 The Traveling Salesman Problem

1 The Traveling Salesman Problem Comp 260: Advanced Algorithms Tufts University, Spring 2018 Prof. Lenore Cowen Scribe: Duc Nguyen Lecture 3a: The Traveling Salesman Problem 1 The Traveling Salesman Problem The Traveling Salesman Problem

More information

Graphs. What is a Graph? Computer Science S-111 Harvard University David G. Sullivan, Ph.D.

Graphs. What is a Graph? Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Unit 10 Graphs Computer Science S-111 Harvard University David G. Sullivan, Ph.D. What is a Graph? vertex / node edge / arc e b d f h j a c i g A graph consists of: a set of vertices (also known as nodes)

More information

Graph Applications, Class Notes, CS 3137 1 Traveling Salesperson Problem Web References: http://www.tsp.gatech.edu/index.html http://www-e.uni-magdeburg.de/mertens/tsp/tsp.html TSP applets A Hamiltonian

More information

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first.

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first. Advanced Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras Lecture 19 Network Models In this lecture, we will discuss network models. (Refer

More information

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

Module 6 P, NP, NP-Complete Problems and Approximation Algorithms Module 6 P, NP, NP-Complete Problems and Approximation Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu

More information

22 Elementary Graph Algorithms. There are two standard ways to represent a

22 Elementary Graph Algorithms. There are two standard ways to represent a VI Graph Algorithms Elementary Graph Algorithms Minimum Spanning Trees Single-Source Shortest Paths All-Pairs Shortest Paths 22 Elementary Graph Algorithms There are two standard ways to represent a graph

More information

Questions... How does one show the first problem is NP-complete? What goes on in a reduction? How hard are NP-complete problems?

Questions... How does one show the first problem is NP-complete? What goes on in a reduction? How hard are NP-complete problems? Even More NP Questions... How does one show the first problem is NP-complete? What goes on in a reduction? How hard are NP-complete problems? Reduction We say that problem A reduces to problem B, if there

More information

Theorem 2.9: nearest addition algorithm

Theorem 2.9: nearest addition algorithm There are severe limits on our ability to compute near-optimal tours It is NP-complete to decide whether a given undirected =(,)has a Hamiltonian cycle An approximation algorithm for the TSP can be used

More information

Using a Divide and Conquer Method for Routing in a PC Vehicle Routing Application. Abstract

Using a Divide and Conquer Method for Routing in a PC Vehicle Routing Application. Abstract Using a Divide and Conquer Method for Routing in a PC Vehicle Routing Application Brenda Cheang Department of Management Information Systems University College Dublin Belfield, Dublin 4, Ireland. Sherlyn

More information

The Algorithm Design Manual

The Algorithm Design Manual Steven S. Skiena The Algorithm Design Manual With 72 Figures Includes CD-ROM THE ELECTRONIC LIBRARY OF SCIENCE Contents Preface vii I TECHNIQUES 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 2 2.1 2.2 2.3

More information

Construction of Minimum-Weight Spanners Mikkel Sigurd Martin Zachariasen

Construction of Minimum-Weight Spanners Mikkel Sigurd Martin Zachariasen Construction of Minimum-Weight Spanners Mikkel Sigurd Martin Zachariasen University of Copenhagen Outline Motivation and Background Minimum-Weight Spanner Problem Greedy Spanner Algorithm Exact Algorithm:

More information

Algorithm Design Techniques. Hwansoo Han

Algorithm Design Techniques. Hwansoo Han Algorithm Design Techniques Hwansoo Han Algorithm Design General techniques to yield effective algorithms Divide-and-Conquer Dynamic programming Greedy techniques Backtracking Local search 2 Divide-and-Conquer

More information

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS) COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section 35.1-35.2(CLRS) 1 Coping with NP-Completeness Brute-force search: This is usually only a viable option for small

More information

ME/CS 132: Advanced Robotics: Navigation and Vision

ME/CS 132: Advanced Robotics: Navigation and Vision ME/CS 132: Advanced Robotics: Navigation and Vision Lecture #5: Search Algorithm 1 Yoshiaki Kuwata 4/12/2011 Lecture Overview Introduction Label Correcting Algorithm Core idea Depth-first search Breadth-first

More information

CSE 100 Minimum Spanning Trees Prim s and Kruskal

CSE 100 Minimum Spanning Trees Prim s and Kruskal CSE 100 Minimum Spanning Trees Prim s and Kruskal Your Turn The array of vertices, which include dist, prev, and done fields (initialize dist to INFINITY and done to false ): V0: dist= prev= done= adj:

More information

Computational Geometry

Computational Geometry Lecture 12: Lecture 12: Motivation: Terrains by interpolation To build a model of the terrain surface, we can start with a number of sample points where we know the height. Lecture 12: Motivation: Terrains

More information

Understand graph terminology Implement graphs using

Understand graph terminology Implement graphs using raphs Understand graph terminology Implement graphs using djacency lists and djacency matrices Perform graph searches Depth first search Breadth first search Perform shortest-path algorithms Disjkstra

More information

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list UNIT-4 Graph: Terminology, Representation, Traversals Applications - spanning trees, shortest path and Transitive closure, Topological sort. Sets: Representation - Operations on sets Applications. 1. Name

More information

Minimum Spanning Trees COSC 594: Graph Algorithms Spring By Kevin Chiang and Parker Tooley

Minimum Spanning Trees COSC 594: Graph Algorithms Spring By Kevin Chiang and Parker Tooley Minimum Spanning Trees COSC 594: Graph Algorithms Spring 2017 By Kevin Chiang and Parker Tooley Test Questions 1. What is one NP-Hard problem for which Minimum Spanning Trees is a good approximation for?

More information

2. Optimization problems 6

2. Optimization problems 6 6 2.1 Examples... 7... 8 2.3 Convex sets and functions... 9 2.4 Convex optimization problems... 10 2.1 Examples 7-1 An (NP-) optimization problem P 0 is defined as follows Each instance I P 0 has a feasibility

More information

Review for Midterm Exam

Review for Midterm Exam Review for Midterm Exam 1 Policies and Overview midterm exam policies overview of problems, algorithms, data structures overview of discrete mathematics 2 Sample Questions on the cost functions of algorithms

More information

Reference Sheet for CO142.2 Discrete Mathematics II

Reference Sheet for CO142.2 Discrete Mathematics II Reference Sheet for CO14. Discrete Mathematics II Spring 017 1 Graphs Defintions 1. Graph: set of N nodes and A arcs such that each a A is associated with an unordered pair of nodes.. Simple graph: no

More information

tree follows. Game Trees

tree follows. Game Trees CPSC-320: Intermediate Algorithm Design and Analysis 113 On a graph that is simply a linear list, or a graph consisting of a root node v that is connected to all other nodes, but such that no other edges

More information

Graphs. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. What is a Graph? b d f h j

Graphs. Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. What is a Graph? b d f h j Graphs Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. What is a Graph? vertex / node edge / arc e b d f h j a c i g A graph consists of: a set of vertices (also known

More information

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2: Search. Problem Solving Agents

Class Overview. Introduction to Artificial Intelligence COMP 3501 / COMP Lecture 2: Search. Problem Solving Agents Class Overview COMP 3501 / COMP 4704-4 Lecture 2: Search Prof. 1 2 Problem Solving Agents Problem Solving Agents: Assumptions Requires a goal Assume world is: Requires actions Observable What actions?

More information

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach

CSC Design and Analysis of Algorithms. Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms. Brute-Force Approach CSC 8301- Design and Analysis of Algorithms Lecture 4 Brute Force, Exhaustive Search, Graph Traversal Algorithms Brute-Force Approach Brute force is a straightforward approach to solving a problem, usually

More information

Lecture 8: The Traveling Salesman Problem

Lecture 8: The Traveling Salesman Problem Lecture 8: The Traveling Salesman Problem Let G = (V, E) be an undirected graph. A Hamiltonian cycle of G is a cycle that visits every vertex v V exactly once. Instead of Hamiltonian cycle, we sometimes

More information

Weighted Graph Algorithms Presented by Jason Yuan

Weighted Graph Algorithms Presented by Jason Yuan Weighted Graph Algorithms Presented by Jason Yuan Slides: Zachary Friggstad Programming Club Meeting Weighted Graphs struct Edge { int u, v ; int w e i g h t ; // can be a double } ; Edge ( int uu = 0,

More information

GRAPHS Lecture 19 CS2110 Spring 2013

GRAPHS Lecture 19 CS2110 Spring 2013 GRAPHS Lecture 19 CS2110 Spring 2013 Announcements 2 Prelim 2: Two and a half weeks from now Tuesday, April16, 7:30-9pm, Statler Exam conflicts? We need to hear about them and can arrange a makeup It would

More information

L21: Putting it together: Tree Search (Ch. 6)!

L21: Putting it together: Tree Search (Ch. 6)! Administrative CUDA project due Wednesday, Nov. 28 L21: Putting it together: Tree Search (Ch. 6)! Poster dry run on Dec. 4, final presentations on Dec. 6 Optional final report (4-6 pages) due on Dec. 14

More information

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Introduction to Algorithms Preface xiii 1 Introduction 1 1.1 Algorithms 1 1.2 Analyzing algorithms 6 1.3 Designing algorithms 1 1 1.4 Summary 1 6

More information

Topic 10 Part 2 [474 marks]

Topic 10 Part 2 [474 marks] Topic Part 2 [474 marks] The complete graph H has the following cost adjacency matrix Consider the travelling salesman problem for H a By first finding a minimum spanning tree on the subgraph of H formed

More information

Job Shop Scheduling Problem (JSSP) Genetic Algorithms Critical Block and DG distance Neighbourhood Search

Job Shop Scheduling Problem (JSSP) Genetic Algorithms Critical Block and DG distance Neighbourhood Search A JOB-SHOP SCHEDULING PROBLEM (JSSP) USING GENETIC ALGORITHM (GA) Mahanim Omar, Adam Baharum, Yahya Abu Hasan School of Mathematical Sciences, Universiti Sains Malaysia 11800 Penang, Malaysia Tel: (+)

More information

- Logic and Algorithms - Graph Algorithms

- Logic and Algorithms - Graph Algorithms Fundamentals of Computer Sience and Digital Communications - Logic and Algorithms - Graph Algorithms Johan Larsson Marco Loh 22..24 Overview What is a Graph? Representations of Graphs Breadth-first Search

More information

ECE250: Algorithms and Data Structures Final Review Course

ECE250: Algorithms and Data Structures Final Review Course ECE250: Algorithms and Data Structures Final Review Course Ladan Tahvildari, PEng, SMIEEE Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University of Waterloo

More information

Review of Graph Theory. Gregory Provan

Review of Graph Theory. Gregory Provan Review of Graph Theory Gregory Provan Overview Need for graphical models of computation Cloud computing Data centres Telecommunications networks Graph theory Graph Models for Cloud Computing Integration

More information

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee

Algorithm Analysis Graph algorithm. Chung-Ang University, Jaesung Lee Algorithm Analysis Graph algorithm Chung-Ang University, Jaesung Lee Basic definitions Graph = (, ) where is a set of vertices and is a set of edges Directed graph = where consists of ordered pairs

More information

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville

Computer Science and Software Engineering University of Wisconsin - Platteville. 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville Computer Science and Software Engineering University of Wisconsin - Platteville 3. Search (Part 1) CS 3030 Lecture Notes Yan Shi UW-Platteville Read: Textbook Chapter 3.7-3.9,3.12, 4. Problem Solving as

More information

CS521 \ Notes for the Final Exam

CS521 \ Notes for the Final Exam CS521 \ Notes for final exam 1 Ariel Stolerman Asymptotic Notations: CS521 \ Notes for the Final Exam Notation Definition Limit Big-O ( ) Small-o ( ) Big- ( ) Small- ( ) Big- ( ) Notes: ( ) ( ) ( ) ( )

More information

TOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5

TOTAL CREDIT UNITS L T P/ S SW/F W. Course Title: Analysis & Design of Algorithm. Course Level: UG Course Code: CSE303 Credit Units: 5 Course Title: Analysis & Design of Algorithm Course Level: UG Course Code: CSE303 Credit Units: 5 L T P/ S SW/F W TOTAL CREDIT UNITS 3 1 2-5 Course Objectives: The designing of algorithm is an important

More information

Chapter S:I. I. Introduction. Examples for Search Problems Search Problem Abstraction

Chapter S:I. I. Introduction. Examples for Search Problems Search Problem Abstraction Chapter S:I I. Introduction Examples for Search Problems Search Problem Abstraction S:I-1 Introduction STEIN/LETTMANN 1998-2016 Road Map Problem Search for a route from place A to : A S:I-2 Introduction

More information

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May

R10 SET - 1. Code No: R II B. Tech I Semester, Supplementary Examinations, May www.jwjobs.net R10 SET - 1 II B. Tech I Semester, Supplementary Examinations, May - 2012 (Com. to CSE, IT, ECC ) Time: 3 hours Max Marks: 75 *******-****** 1. a) Which of the given options provides the

More information

Introduction to Optimization

Introduction to Optimization Introduction to Optimization Greedy Algorithms October 28, 2016 École Centrale Paris, Châtenay-Malabry, France Dimo Brockhoff Inria Saclay Ile-de-France 2 Course Overview Date Fri, 7.10.2016 Fri, 28.10.2016

More information

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value

The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value The ADT priority queue Orders its items by a priority value The first item removed is the one having the highest priority value 1 Possible implementations Sorted linear implementations o Appropriate if

More information

L20: Putting it together: Tree Search (Ch. 6)!

L20: Putting it together: Tree Search (Ch. 6)! Administrative L20: Putting it together: Tree Search (Ch. 6)! November 29, 2011! Next homework, CUDA, MPI (Ch. 3) and Apps (Ch. 6) - Goal is to prepare you for final - We ll discuss it in class on Thursday

More information

Module 11: Additional Topics Graph Theory and Applications

Module 11: Additional Topics Graph Theory and Applications Module 11: Additional Topics Graph Theory and Applications Topics: Introduction to Graph Theory Representing (undirected) graphs Basic graph algorithms 1 Consider the following: Traveling Salesman Problem

More information

L.J. Institute of Engineering & Technology Semester: VIII (2016)

L.J. Institute of Engineering & Technology Semester: VIII (2016) Subject Name: Design & Analysis of Algorithm Subject Code:1810 Faculties: Mitesh Thakkar Sr. UNIT-1 Basics of Algorithms and Mathematics No 1 What is an algorithm? What do you mean by correct algorithm?

More information

Introduction to Approximation Algorithms

Introduction to Approximation Algorithms Introduction to Approximation Algorithms Dr. Gautam K. Das Departmet of Mathematics Indian Institute of Technology Guwahati, India gkd@iitg.ernet.in February 19, 2016 Outline of the lecture Background

More information

Graphs & Digraphs Tuesday, November 06, 2007

Graphs & Digraphs Tuesday, November 06, 2007 Graphs & Digraphs Tuesday, November 06, 2007 10:34 PM 16.1 Directed Graphs (digraphs) like a tree but w/ no root node & no guarantee of paths between nodes consists of: nodes/vertices - a set of elements

More information

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 Asymptotics, Recurrence and Basic Algorithms 1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1 1. O(logn) 2. O(n) 3. O(nlogn) 4. O(n 2 ) 5. O(2 n ) 2. [1 pt] What is the solution

More information

( ) 1 B. 1. Suppose f x

( ) 1 B. 1. Suppose f x CSE Name Test Spring Last Digits of Student ID Multiple Choice. Write your answer to the LEFT of each problem. points each is a monotonically increasing function. Which of the following approximates the

More information

CAD Algorithms. Categorizing Algorithms

CAD Algorithms. Categorizing Algorithms CAD Algorithms Categorizing Algorithms Mohammad Tehranipoor ECE Department 2 September 2008 1 Categorizing Algorithms Greedy Algorithms Prim s Algorithm (Minimum Spanning Tree) A subgraph that is a tree

More information

From Routing to Traffic Engineering

From Routing to Traffic Engineering 1 From Routing to Traffic Engineering Robert Soulé Advanced Networking Fall 2016 2 In the beginning B Goal: pair-wise connectivity (get packets from A to B) Approach: configure static rules in routers

More information

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m

1 Minimum Spanning Trees (MST) b 2 3 a. 10 e h. j m Minimum Spanning Trees (MST) 8 0 e 7 b 3 a 5 d 9 h i g c 8 7 6 3 f j 9 6 k l 5 m A graph H(U,F) is a subgraph of G(V,E) if U V and F E. A subgraph H(U,F) is called spanning if U = V. Let G be a graph with

More information

Graphs. Computer Science E-22 Harvard Extension School David G. Sullivan, Ph.D. What is a Graph? b d f h j

Graphs. Computer Science E-22 Harvard Extension School David G. Sullivan, Ph.D. What is a Graph? b d f h j Graphs Computer Science E-22 Harvard Extension School David G. Sullivan, Ph.D. What is a Graph? vertex / node edge / arc e b d f h j a c i g A graph consists of: a set of vertices (also known as nodes)

More information

Minimum-weight tree shortcutting for Metric TSP

Minimum-weight tree shortcutting for Metric TSP Minimum-weight tree shortcutting for Metric TSP 2 Vladimir Deineko and Alexander Tiskin Warwick Business School and Department of Computer Science University of Warwick Deineko and Tiskin (Warwick) Min

More information

r=1 The Binomial Theorem. 4 MA095/98G Revision

r=1 The Binomial Theorem. 4 MA095/98G Revision Revision Read through the whole course once Make summary sheets of important definitions and results, you can use the following pages as a start and fill in more yourself Do all assignments again Do the

More information

Notes for Lecture 24

Notes for Lecture 24 U.C. Berkeley CS170: Intro to CS Theory Handout N24 Professor Luca Trevisan December 4, 2001 Notes for Lecture 24 1 Some NP-complete Numerical Problems 1.1 Subset Sum The Subset Sum problem is defined

More information

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1 Graphs The ultimate data structure graphs 1 Definition of graph Non-linear data structure consisting of nodes & links between them (like trees in this sense) Unlike trees, graph nodes may be completely

More information

CS/COE

CS/COE CS/COE 1501 www.cs.pitt.edu/~lipschultz/cs1501/ Weighted Graphs Last time, we said spatial layouts of graphs were irrelevant We define graphs as sets of nodes and edges However, we ll certainly want to

More information

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC)

R13. II B. Tech I Semester Supplementary Examinations, May/June DATA STRUCTURES (Com. to ECE, CSE, EIE, IT, ECC) SET - 1 II B. Tech I Semester Supplementary Examinations, May/June - 2016 PART A 1. a) Write a procedure for the Tower of Hanoi problem? b) What you mean by enqueue and dequeue operations in a queue? c)

More information

V 2 Clusters, Dijkstra, and Graph Layout"

V 2 Clusters, Dijkstra, and Graph Layout Bioinformatics 3! V 2 Clusters, Dijkstra, and Graph Layout" Mon, Oct 21, 2013" Graph Basics" A graph G is an ordered pair (V, E) of a set V of vertices and a set E of edges." Degree distribution P(k)!

More information