Download presentation

Presentation is loading. Please wait.

Published byGwen Richardson Modified over 2 years ago

1
1 Dijkstra’s Minimum-Path Algorithm Minimum Spanning Tree CSE 30331 Lectures 20 – Intro to Graphs

2
2 Minimum (weight) path – Dijkstra’s algorithm Uses priority queue containing identities of all fringe vertices and the length of the minimum path to each from the start Algorithm builds a tree of all minimum length paths from start Each vertex is either tree, fringe or unseen At each step The fringe vertex V with the minimum path is removed from priorityQ and added to the tree V’s non-tree neighbors U become fringe and the minimum path length is computed from start, thru V to U and is stored in U.dataValue, V is saved as U.parent and U is added to priorityQ Process stops when queue is empty, or chosen destination vertex is found

3
3 Dijkstra Minimum-Path Algorithm (Example A to D) PriQ:(A,0)Tree (vertices & path weight) (B,4)(C,11)(E,4)A,0 (E,4)(C,11)(C,10)(D,12)A,0B,4 (C,10)(C,11)(D,12)A,0B,4E,4 (C,11)(D,12)A,0B,4E,4C,10 (D,12) A,0B,4E,4C,10 empty A,0B,4E,4C,10D,12

4
4 Minimum Spanning Tree Prim’s Algorithm Spanning tree for graph with minimum TOTAL weight Minimum Spanning Tree may not be unique, but total weight is same value for all All vertices are either tree, fringe, or unseen Priority queue is used to hold fringe vertices and the minimum weight edge connecting each to the tree Put start vertex in priorityQ While priorityQ not empty The nearest vertex V is removed from the queue and added to the tree For each non-tree neighbor U of V if the edge V,U weight < current U.dataValue U.dataValue is set to weight of edge V,U U.parent is set to V push U:weight pair onto priority queue

5
5 Minimum Spanning Tree Example

6
6 Minimum Spanning Tree: Step 1 (edge A-B) A B C D 2 8 12 5 7 A B 2 Spanning tree with vertices A, B minSpanTreeSize = 2, minTreeWeight = 2

7
7 Minimum Spanning Tree: Step 2 (Edge A-D) A B C D 2 8 12 5 7 D A B Spanning tree with vertices A, B, D minSpanTreeSize = 3, minTreeWeight = 7 2 5

8
8 Minimum Spanning Tree: Step 3 (Edge D-C) A B C D 2 8 12 5 7 C 7 D A B Spanning tree with vertices A, B, D, C minSpanTreeSize = 4, minTreeWeight = 14 2 5

9
9 Runtime Orders of Complexity Min Spanning Tree – O(V + E log 2 E) Min Path (Dijkstra) – O(V + E log 2 E) Strong Components – O(V + E) Dfs – O(V+E) BFS – O(V+E)

10
10 Graphs – Important Terms Vertex, edge, adjacency, path, cycle Directed (digraph), undirected Complete Connected (strongly, weakly, components) Searches (DFS, BFS) Shortest Path, Minimum Path Euler Path, Hamiltonian Path Minimum Spanning Tree

11
11 Searching Graphs Breadth-First Search, bfs() Locates all vertices reachable from a starting vertex Uses a queue in process Can be used to find the minimum distance from a starting vertex to an ending vertex in a graph.

12
12 Searching Graphs Depth-First Search, dfs() Produces a list of all graph vertices in the reverse order of their finishing times. Supported by a recursive depth-first visit function, dfsVisit() An algorithm can check to see whether a graph is acyclic (has no cycles) and can perform a topological sort of a directed acyclic graph (DAG) Forms the basis for an efficient algorithm that finds the strong components of a graph

13
13 Searching Graphs Dijkstra's algorithm (minimum path) Uses a priority queue to determine a path from a starting to an ending vertex, of minimum weight Prim's algorithm (minimum spanning tree) An extension of Dijkstra’s algorithm, which computes the minimum spanning tree of an undirected, connected graph.

14
14 Alaska Road Map Assignment File format Demo

Similar presentations

OK

Fundamentals, Terminology, Traversal, Algorithms Graph Algorithms Telerik Algo Academy

Fundamentals, Terminology, Traversal, Algorithms Graph Algorithms Telerik Algo Academy

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

A ppt on football Ppt on data handling for grade 3 Ppt on 2 stroke ic engines Ppt on waxes definition Ppt on central administrative tribunal india Ppt on dc motor drives Ppt on force and friction for class 8 Ppt on formal education vs informal education Ppt on conceptual art definition Ppt on credit policy variables