L3-Network Algorithms L3 – Network Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov. 2015 by Abdulghani.

Slides:



Advertisements
Similar presentations
Problem solving with graph search
Advertisements

Part A - Terminology and Traversals
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Chapter 8, Part I Graph Algorithms.
Graphs Graphs are the most general data structures we will study in this course. A graph is a more general version of connected nodes than the tree. Both.
Data Structure and Algorithms (BCS 1223) GRAPH. Introduction of Graph A graph G consists of two things: 1.A set V of elements called nodes(or points or.
CS171 Introduction to Computer Science II Graphs Strike Back.
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1.
9.2 The Traveling Salesman Problem. Let us return to the question of finding a cheapest possible cycle through all the given towns: We have n towns (points)
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
Graph & BFS.
7.3 Kruskal’s Algorithm. Kruskal’s Algorithm was developed by JOSEPH KRUSKAL.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Graphs CS-240/341. Uses for Graphs computer networks and routing airline flights geographic maps course prerequisite structures tasks for completing a.
Graphs. Graph definitions There are two kinds of graphs: directed graphs (sometimes called digraphs) and undirected graphs Birmingham Rugby London Cambridge.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Graphs & Graph Algorithms 2 Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Using Search in Problem Solving
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Trip Planning Queries F. Li, D. Cheng, M. Hadjieleftheriou, G. Kollios, S.-H. Teng Boston University.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Theory of Computing Lecture 10 MAS 714 Hartmut Klauck.
Algorithms for Network Optimization Problems This handout: Minimum Spanning Tree Problem Approximation Algorithms Traveling Salesman Problem.
CSCI-455/552 Introduction to High Performance Computing Lecture 18.
Chapter 9 – Graphs A graph G=(V,E) – vertices and edges
SPANNING TREES Lecture 21 CS2110 – Spring
Chapter 2 Graph Algorithms.
Graph Theory Topics to be covered:
COSC 2007 Data Structures II Chapter 14 Graphs III.
Representing and Using Graphs
Algorithm Course Dr. Aref Rashad February Algorithms Course..... Dr. Aref Rashad Part: 5 Graph Algorithms.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Graphs.
Graph Traversal BFS & DFS. Review of tree traversal methods Pre-order traversal In-order traversal Post-order traversal Level traversal a bc d e f g hi.
Graphs. Definitions A graph is two sets. A graph is two sets. –A set of nodes or vertices V –A set of edges E Edges connect nodes. Edges connect nodes.
Lecture 12: Algorithm Review. General Problem Solving Methods Divide & Conquer Greedy Method Dynamic Programming Graph & Tree Traversal Backtracking Branch.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Graphs 1 Definition 2 Terminology 3 Properties 4 Internal representation Adjacency list Adjacency matrix 5 Exploration algorithms 6 Other algorithms.
Most of contents are provided by the website Graph Essentials TJTSD66: Advanced Topics in Social Media.
L1-Spatial Concepts NGEN06 & TEK230: Algorithms in Geographical Information Systems by: Irene Rangel, updated by Sadegh Jamali 1.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
Graphs. Graphs Similar to the graphs you’ve known since the 5 th grade: line graphs, bar graphs, etc., but more general. Those mathematical graphs are.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Ver Chapter 13: Graphs Data Abstraction & Problem Solving with C++
1 Directed Graphs Chapter 8. 2 Objectives You will be able to: Say what a directed graph is. Describe two ways to represent a directed graph: Adjacency.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
SPANNING TREES Lecture 21 CS2110 – Fall Nate Foster is out of town. NO 3-4pm office hours today!
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graph Revisited Fei Chen CSCI2100B Data Structures Tutorial 12 1.
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
Graphs. Introduction Graphs are a collection of vertices and edges Graphs are a collection of vertices and edges The solid circles are the vertices A,
1 GRAPHS – Definitions A graph G = (V, E) consists of –a set of vertices, V, and –a set of edges, E, where each edge is a pair (v,w) s.t. v,w  V Vertices.
Graphs. What is a graph? In simple words, A graph is a set of vertices and edges which connect them. A node (or vertex) is a discrete position in the.
1 Minimum Spanning Tree: Solving TSP for Metric Graphs using MST Heuristic Soheil Shafiee Shabnam Aboughadareh.
C.Eng 213 Data Structures Graphs Fall Section 3.
Comp 245 Data Structures Graphs.
Graphs Representation, BFS, DFS
Graphs & Graph Algorithms 2
Graphs Chapter 11 Objectives Upon completion you will be able to:
CSE 373: Data Structures and Algorithms
Graphs.
Chapter 11 Graphs.
Shortest Paths and Minimum Spanning Trees
Chapter 15 Graphs © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Graphs.
Spanning Trees Lecture 20 CS2110 – Spring 2015.
Approximation Algorithms
More Graphs Lecture 19 CS2110 – Fall 2009.
Presentation transcript:

L3-Network Algorithms L3 – Network Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov by Abdulghani Hasan

L3-Network Algorithms Background By using the distances between nodes in a network we can derive the shortest path, Minimum number of nodes to pass, and other interesting quantities in GIS. Shortest path -> Dijkstra’s algorithm

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

L3-Network Algorithms Aim  Understand how an algorithm can use geographic information stored in a network.  Get knowledge about the shortest path problem and Dijkstra’s algorithm.

L3-Network Algorithms General issues of networks Many analysis in networks only consider the nodes and the edges. A network or graph has 2 main constitutes: –Nodes –Edges street network airplane routes Geometric location of the nodes is uninteresting Edges = (distances between nodes)

L3-Network Algorithms General issues of networks ABCD A021- B2032 C1304 D-240 Networks can be stored in matrixes. ”-” implies that the nodes are not connected by any edge In most cases relational databases or lists and trees are more suitable storage structures. Not a good data storage since it requires a lot of memory.

L3-Network Algorithms Graphic representation Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004

L3-Network Algorithms Shortest path The path between two nodes that is shorter than all the 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. Dijkstra’s algorithm is one of the most well- known shortest path algorithms.

L3-Network Algorithms Shortest path Navigation Start point  target point Accessibility Many points  target point

L3-Network Algorithms Dijkstra’s algorithm Example of finding the shortest path between nodes A and D. We need 2 matrixes: –Adjacency matrix –State matrix (dynamic) ABCD A021- B2032 C1304 D-240 NodeDistancePathVisited A0AYes B2ANo C1A D  -

L3-Network Algorithms Dijkstra’s algorithm State matrix –Distance keeps track of the current shortes distance from the starting node to this node. –Path stores the previous node along the shortes path (found so far) to this node. –Visited describes is the node has been visited in the computations of the shortest path. Start point is A NodeDistancePathVisited A B C D NodeDistancePathVisited A0AYes B2ANo C1A D  - NodeDistancePathVisited A0 B2 C1 D  NodeDistancePathVisited A0A B2A C1A D  -

L3-Network Algorithms Dijkstra’s algorithm Initialized state matrix Initialization of the state matrix: –The start node is marked as visited. –All the nodes that can be reached from the start node have been updated in the columns distance and path. Distance values are set to the distances between the start node and the respective node (use 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 known path to some nodes, their distance is set to infinity and their path value are undefined. The state matrix is initialized for start point A NodeDistancePathVisited A0AYes B2ANo C1A D  - NodeDistancePathVisited A0AYes B2ANo C1A D  -

L3-Network Algorithms Dijkstra’s algorithm 0. Initialize the state matrix. 1.Find the node which has the shortest distance and is not yet visited. Denote this as the current node. 2.Mark the current node as visited. Stop Criteria: End node 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 the sum of the distances for the start node to current node and from current node to 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.

L3-Network Algorithms Result of the shortest path algorithm Distance from start to end node Path NodeDistancePathVisited A0-Yes B2A C1A D4B

L3-Network Algorithms Dijkstra’s algorithm This algorithm does not search along a possible path direction depth-first BUT rather in all directions breadth-first.

L3-Network Algorithms Does Dijkstra’s algorithm always give a correct answer? 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)

L3-Network Algorithms Other shortest path algorithms Heuristic 1 – Direction limitation A* algorithm Euclidean distances, depth-first & breadth-first Heuristic 2 – Hierarchical algorithm Minor roads and major roads Heuristic 2 – super nodes (transit nodes) Algorithms with heuristics are not always giving the best answer (only a reasonably good answer is guaranteed).

L3-Network Algorithms Breadth-first traversal Q is a queu – property is first-in-first-out b is the starting point Source: Worboys and Duckham 2004

L3-Network Algorithms Depth-first traversal S is a stack – property is last-in-first-out b is the starting point Source: Worboys and Duckham 2004

L3-Network Algorithms Neighbourhood graphs – minimum spanning tree (MST) Minimum Spanning Tree (MST) 1.No isolated node 2.

L3-Network Algorithms Source: Sedgewick 2002 Kruskal’s algorithm for computing MST OriginalOrdered Edges

L3-Network Algorithms Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1.No isolated node 2. Threshold distance

L3-Network Algorithms Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1.No isolated node 2. Threshold distance

L3-Network Algorithms Traveling salesman problem (TSP)

L3-Network Algorithms Traveling salesman problem (TSP) 1.Begin and end in the same node. 2.Visit all nodes. 3.Minimize total length of the route. NP-complete

L3-Network Algorithms Traveling salesman problem (TSP) A possible way is to compute all possible combinations and chose the shortest one. This would, of course, take exponential time. How to solve the TSP problems? A more sensible approach, is to use heuristics. One approach is to start to compute the MST (by e.g. Kruskal’s algorithm). The maximum length of the TSP is at most 2 times the total length of the MST

L3-Network Algorithms Traveling salesman problem (TSP) This solution can greatly been improve by making short cuts. Start by the MST Make iterative improvements when they found. until no further improvements are possible. A local optimum of the TSP is found. How to solve the TSP problems?