Download presentation

Presentation is loading. Please wait.

Published byCollin Booker Modified over 2 years ago

1
Midwestern State University Department of Computer Science Dr. Ranette Halverson CMPS 2433 CHAPTER 4 - PART 2 GRAPHS 1

2
2 4.3 Shortest Paths & Distance Traversal: process visiting every vertex Tree or Graph Is a traversal necessary to solve a particular problem? Breadth-first vs Depth-first searches & traversals Distance between 2 vertices: number of edges on the shortest path between 2 vertices (may be more than one path)

3
3 Shortest Paths & Distance Traversal Distance Breadth-first Depth-first

4
4 Finding Distances – Breadth-first PROBLEM: Find distance between vertex A and all other vertices in the graph Notation: Vertex label 4(F) means distance from A to current vertex is distance 4 and predecessor node on the path is F Let A be vertex 1 Label on vertex 4 is 2(5)

5
5 Finding Distances – Breadth-first PROBLEM: Find distance between vertex A and all other vertices in the graph Choose start vertex 1 – label 0(-) Label all vertices adjacent to vertex 1 Repeat for newly labeled vertices (never change label on vertex) Continue until all vertices are labeled.

6
6 Breadth-First Search Algorithm Page 183 Complexity Process each vertex & edge once v + e ops Remember: e <= C(v,2) = (v (v-1))/2 - - Why? v + (v (v-1))/2 O(v 2 )

7
7 Weighted Graphs Graph in which a number = weight is assigned to each edge Weight of Path: sum of edges in path Used in MANY applications Distance, Cost, Size Shortest Path Problems

8
8 Dijkstra’s Algorithm Finds shortest path between a designated vertex S & all other vertices in graph & provides actual shortest paths Overview: Start at S Find nodes adjacent Each step update with shorter path, if available

9
9 Dijkstra’s Algorithm - Overview 10 3 5 1 4 S A B C

10
Number of Paths Theorem 4.7 (unweighted graph) For a graph G with vertices V1, V2,…Vn & adjacency matrix A, the number of paths of length m from Vi to Vj is the (i, j) entry of A m. See example on page 189-190 Review Matrix Multiplication!!

11
11 Flubber Graphs Named after a professor who developed in 1960’s Not in our book Flubber Graph: A graph (set of vertices & edges) in which each vertex is flubberized.

12
12 Homework Section 4.3 – pages 190-193 Exercises – All 1 – 16, 20 1 – 4, Breadth-first algorithm, 5 – 8, Dijkstra’s Algorithm 9 – 12, modified Dijkstra’s, 13 – 16, Theorem 4.7

13
13 Graph Definitions Flubber Graph A graph in which each vertex is flubberized Connected Graph A graph in which each vertex is connected

14
14 Graph Definitions Flubber Graph A graph in which each vertex is flubberized A graph in which each vertex is flubberized with every other vertex Connected Graph A graph in which each vertex is connected A graph in which each vertex is connected to every other vertex

15
15 4.4 Coloring a Graph Omit section but define problem

16
16 4.5 Directed Graphs - Multigraphs Directed Graph: finite, non-empty set V and E (vertices & edges) in which each edge has specified direction between vertices Directed Edge: An edge (A,B) is from vertex A to B, but not vice versa Degree In degree: # of edges directed into a vertex Out degree: # of edges directed from a vertex

17
17 Representation of Directed Graphs Adjacency Matrix: works but matrix is not symmetrical Adjacency List: also works Directed Graph with weighted edges Must also store the weights Multigraph Parallel Directed Edges: Represent? Loop: Represent?

18
18 Paths in Directed Graphs Directed Path: sequence of edges from vertex A to B, following edge direction Length of Path: number of edges on path Simple Directed Path: No repeated vertices Directed cycle Strongly Connected: A directed multigraph which contains a path from vertex A to B for every pair of vertices Means A to B & B to A

19
19 Homework Section 4.5 – Pages 212 – 218 Exercises 1 – 22, 24, 25, 35-37, 74,77 Maybe others later – or just try some others Omit from study pp. 208-212

Similar presentations

OK

Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.

Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Download ppt on indus valley civilization Ppt on coalition government in england Ppt on model united nations Ppt on council of ministers of india Ppt on water scarcity in the world Download ppt on fundamental rights and duties citizens Ppt on conservation of momentum definition Ppt on 21st century skills definition Ppt on linear equations in two variables 6th Ppt on resources of nature