Graphs An abstract way of representing connectivity using
Graphs -An abstract way of representing connectivity using nodes (also called vertices) and edges vertices edges undirected - weighted directed
Ok what is the problem? ? ? -Graph representation 5 4 (how to store the graph in program). -Adjacency Matrix -Adjacency List 1 0 7 3 - Graph Traversal -Depth-First Search (DFS) : uses recursion (stack) - Breadth-First Search (BFS) : uses queue 2 9 8 6
Graph representation Adjacency Matrix 0 1 23456789 0 0, 0, 1, 0, 0, 1 0, 0, 0, 1, 0, 0, 2 0, 0, 1, 0, 0, 0, 3 0, 0, 1, 4 0, 0, 0, 1, 0, 0, 0, 5 1, 0, 0, 0, 6 0, 0, 1, 0, 7 0, 1, 0, 0, 8 0, 0, 0, 1, 0, 0, 0, 9 0, 0, 0, 5 4 1 0 7 3 2 9 8 6
Graph Traversal Breadth-First Search (BFS) uses queue Depth-First Search (DFS) uses recursion (stack)
Depth-First Search (DFS) uses recursion (stack)
Breadth-First Search (BFS) uses queue
- Slides: 8