Download presentation
Presentation is loading. Please wait.
Published byNeil Hamilton Modified over 9 years ago
1
L3-Network Algorithms L3 – Network Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov. 2015 by Abdulghani Hasan
2
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
3
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.
4
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.
5
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)
6
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.
7
L3-Network Algorithms Graphic representation Adjacency matrix representation Adjacency list representation Source: Worboys and Duckham 2004
8
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.
9
L3-Network Algorithms Shortest path Navigation Start point target point Accessibility Many points target point
10
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 -
11
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 -
12
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 -
13
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.
14
L3-Network Algorithms Result of the shortest path algorithm Distance from start to end node Path NodeDistancePathVisited A0-Yes B2A C1A D4B
15
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.
16
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)
17
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).
18
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
19
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
20
L3-Network Algorithms Neighbourhood graphs – minimum spanning tree (MST) Minimum Spanning Tree (MST) 1.No isolated node 2.
21
L3-Network Algorithms Source: Sedgewick 2002 Kruskal’s algorithm for computing MST OriginalOrdered Edges
22
L3-Network Algorithms Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1.No isolated node 2. Threshold distance
23
L3-Network Algorithms Neighbourhood graphs and Clustering Minimum Spanning Tree (MST) 1.No isolated node 2. Threshold distance
24
L3-Network Algorithms Traveling salesman problem (TSP)
25
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
26
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
27
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?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.