Download presentation
Presentation is loading. Please wait.
Published byClifton Hudson Modified over 8 years ago
1
CSC 213 – Large Scale Programming
2
Today’s Goals Make Britney sad through my color choices Revisit issue of graph terminology and usage Subgraphs, spanning, & connected graphs, oh my! Problems solved or why you should care about these Just rats in a maze: using graphs to find the exit Confident in your decisions: how to travel depth-first Using bread-first searching to cover all the bases 2 algorithms both alike in dignity: how do they differ?
3
Today’s Goals Make Britney sad through my color choices Revisit issue of graph terminology and usage Subgraphs, spanning, & connected graphs, oh my! Problems solved or why you should care about these Just rats in a maze: using graphs to find the exit Confident in your decisions: how to travel depth-first Using bread-first searching to cover all the bases 2 algorithms both alike in dignity: how do they differ?
4
Graphs Solve Many Problems
5
Subgraphs Subgraph of G contains edges & vertices from G Graph
6
Subgraphs Subgraph of G contains edges & vertices from G Subgraph
7
Subgraphs Subgraph of G contains edges & vertices from G Spanning subgraph is subgraph containing all vertices in G Subgraph Graph
8
Subgraphs Subgraph of G contains edges & vertices from G Spanning subgraph is subgraph containing all vertices in G Subgraph Spanning subgraph
9
Connected Graphs & Subgraphs Connected if path exists between all vertex pairs Requires path, not edge, between vertices Connected Graph
10
Connected Graphs & Subgraphs Connected if path exists between all vertex pairs not edge Requires path, not edge, between vertices Disconnected Graph
11
Connected Graphs & Subgraphs Connected if path exists between all vertex pairs not edge Requires path, not edge, between vertices Connected component is subgraph containing all connected vertices Often called “maximally connected” Disconnected Graph Graph
12
Connected Graphs & Subgraphs Connected if path exists between all vertex pairs not edge Requires path, not edge, between vertices Connected component is subgraph containing all connected vertices Often called “maximally connected” Disconnected Graph Graph with 2 connected components
13
Connected Graphs & Subgraphs Connected if path exists between all vertex pairs not edge Requires path, not edge, between vertices Connected component is subgraph containing all connected vertices Often called “maximally connected” Disconnected Graph Graph with 2 connected components
14
Tree Connected acyclic graph Resembles Tree structure Graph
15
Tree Connected acyclic graph Resembles Tree structure Tree
16
Connected acyclic graph Resembles Tree structure Don’t lose forest for trees Forest is graph with multiple trees Tree Graph
17
Tree Connected acyclic graph Resembles Tree structure Don’t lose forest for trees Forest is graph with multiple trees Tree
18
Connected acyclic graph Resembles Tree structure Don’t lose forest for trees Forest is graph with multiple trees Tree Forest
19
Spanning Tree spanning subgraph tree Subgraph that is both spanning subgraph & tree Contains all vertices in graph spanning subgraph Tree connected without any cycles Graph
20
Spanning Tree spanning subgraph tree Subgraph that is both spanning subgraph & tree Contains all vertices in graph spanning subgraph Tree connected without any cycles Tree
21
Spanning Tree spanning subgraph tree Subgraph that is both spanning subgraph & tree Contains all vertices in graph spanning subgraph Tree connected without any cycles Spanning subgraph
22
Spanning Tree spanning subgraph tree Subgraph that is both spanning subgraph & tree Contains all vertices in graph spanning subgraph Tree connected without any cycles Spanning tree
23
Spanning Tree spanning subgraph tree Subgraph that is both spanning subgraph & tree Contains all vertices in graph spanning subgraph Tree connected without any cycles Tree Than Spans Royals?
24
Depth- & Breadth-First Search Common graph traversal algorithms DFS & BFS traversals have common traits Visits all vertices and edges in G Determines whether of not G is connected Finds connected components if G not connected Heavily used Heavily used to solve graph problems
25
DFS and Maze Traversal Classic maze strategy Intersection, corner, & dead end are vertices Corridors become edges Traveled corridors marked Marks trace back to start
26
DFS Example DB A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
27
DFS Example D B A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
28
DFS Example D B A C E ??? discovery edge back edge A visited vertex A unexplored vertex unexplored edge
29
DFS Example D B A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
30
DFS Example DB A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
31
DFS Example DB A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
32
DFS Example DB A C E discovery edge back edge A visited vertex A unexplored vertex unexplored edge
33
Properties of DFS Connected component’s vertices & edges visited Edges visited form spanning tree for component DB A C E
34
Properties of DFS Connected component’s vertices & edges visited Edges visited form spanning tree for component DB A C E
35
L0L0 BFS Example DB A C E discovery edge A visited vertex A unexplored vertex unexplored edge F cross edge
36
L1L1 L0L0 BFS Example D B A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
37
L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
38
L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
39
L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
40
L2L2 L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
41
L2L2 L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
42
L2L2 L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
43
L2L2 L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
44
L2L2 L1L1 L0L0 BFS Example DB A C E F discovery edge A visited vertex A unexplored vertex unexplored edge cross edge
45
Properties of BFS Some properties similar to DFS: Visits all vertices & edges in connected component Component’s spanning tree from discovery edges For each vertex v in L i Spanning tree has exactly i edges on path from s to v All paths in G from s to v have at least i edges L2L2 L1L1 L0L0 B A C D C E F
46
DFS vs. BFS DFSBFS Back edge (v,w) w is ancestor of v in tree of discovery edges Cross edge (v,w) v in same or previous level as w in tree of discovery edges L2L2 L1L1 L0L0 B A C D C E F DB A C E
47
For Next Lecture Weekly assignment available & due Tuesday Gives you good chance to check your understanding Next Fri. 1 st check-in for program assignment #3 Planning now saves time later! Read 13.4.1 – 13.4.3 for class on Monday When using directed edges, what changes needed? Other computations possible for directed graphs?
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.