CS2_40_Graphs_BFS_DFS

CS2_40_Graphs_BFS_DFS - CS2 Module 40 Category: CS Concepts...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2 Module 40 Category: CS Concepts Topic: Graphs Objectives Graphs Searching BFS - DFS
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 2 Introduction to Object Oriented Programming Module 40 CS Concepts Graphs - BFS - DFS
Background image of page 2
Menu Graph Terminology Graph Modeling Searching Breadth First Search Depth First Search
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs :: Terminology A Graph is a set of vertices (nodes) and a set of unordered edges (linked between these nodes). The order of a graph is the number of vertices and the size is the edge count. A path is a set of edges connecting two nodes. A digraph or directed graph has edges (arcs) that flow in only one direction. In an undirected graph, edges flow in either direction.
Background image of page 4
Graphs :: Terminology Vertices (nodes) Edges Still part of graph, even if not connected An undirected graph
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphs :: Terminology A directed graph A path
Background image of page 6
Graphs :: Contrasted to Simple Data Structures Australo- linkus-listus One ‘next’ node No cycles Cromagnan Tree Two children (for binary tree) No cycles Opposable thumb Modern Graph Cycles allowed Numerous adjacencies per node
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
~Graphs :: Terminology Review: A Graph Graph is a set of vertices vertices (nodes) and a set of unordered edges edges (linked between these nodes). The order order of a graph is the number of vertices and the size size is the edge count. A path path is a set of edges connecting two nodes. A digraph digraph or directed directed graph has edges (arcs) that flow in only one direction. In an undirected undirected graph, edges flow in either direction. This is great fodder for a quiz
Background image of page 8
Directed Graphs B F C A E G D Directed edges only allow movement in one direction.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Weighted Edges B F C A E G D 5 3 2 1 4 7 1 2 3 9 9 Edge weights represent cost.
Background image of page 10
Weighted Directed Graphs B F C A E G D Directed edges only allow movement in one direction. 5 3 2 1 4 7 1 2 3 9 9
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Representing Graphs How do we represent a graph that has any number of children or connections? Adjacency matrices, Nodes held in some structure, or Each node has list of children Links held in some kind of structure Each link points to two nodes Which way is best? Depends!
Background image of page 12
Adjacency Matrix To Nodes From Nodes Initially empty Each edge adds an entry Undirected graph can Put in 2 entries per edge Use just upper or lower diagonal Directed graph uses entire matrix Unweighted graph inserts ‘1’ Weighted graph inserts the weight Size is O(N 2 ) Memory is usually sparsely utilized
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Undirected A G B C D E F A G B C D E F - . 5 . . 1 3 5 1 - 7 . 4 . . . 7 - 9 . . . 3 . 9 - 9 . 1 2 4 . 9 - 2 3 . . . . 2 - . - 1 . 3 2 . Weighted Edges B F C A E G D 5 3 2 1 4 7 1 2 3 9 9 Edge weights represent cost.
Background image of page 14
Undirected A G B C D E F A G B C D E F - . 5 . . 1 3 1 - 7 . 4 . . - 9 . . 3 - 9 . 2 - 2 . - - Weighted Edges B F C A E G D 5 3 2 1 4 7 1 2 3 9 9 Edge weights represent cost.
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Directed Weighted Directed Graphs B F C A E G D Directed edges only allow movement in one direction.
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 81

CS2_40_Graphs_BFS_DFS - CS2 Module 40 Category: CS Concepts...

This preview shows document pages 1 - 17. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online