Docsity

Graph Algorithms: Representations, Operations, and Searching Techniques, Lecture notes of Art

Partial preview of the text

Download Graph Algorithms: Representations, Operations, and Searching Techniques and more Lecture notes Art in PDF only on Docsity!

Analysis of Graph

Algorithms

IT 131

Outline

  • (^) Introduction to Graphs
  • (^) Graph Representation
  • (^) Graph Operations
  • (^) Graph Searching

Example: 5 vertices; 7 edges

1 2 4 3 5

Vertices V = {1, 2, 3, 4, 5} Edges E = { (1,2), (2,3), (3,4), (4,5), (5,1), (3,5), (5,2)}

Example:

#1 Answer the following:

  1. Is the graph directed or not?
  2. Are nodes 1 & 4 connected?
  3. List all pairs of nodes which are connected or adjacent.
  4. Define a path from node 1 to node 5.

#2 Answer the following:

  1. Define all paths from node a to node b.
  2. What is the shortest path from a to b?
  3. List all paths from node a to any other node.
  4. Determine all pairs of nodes which are adjacent.

Weighted / Undirected Graph

a b c e d f

Weighted / Directed Graph

a b e f

#4 Answer the following:

  1. Define all paths from a to b.
  2. What is the weight of each path?
  3. What is the shortest path?

Example: Adjacency Matrix

V 1 2 3 4 5 1 0 1 0 0 0 2 0 0 1 0 0 3 0 0 0 1 1 4 0 0 0 0 1 5 1 1 0 0 0

Example: Adjacency List

  • 1 
  • 2 
  • 3  4 
  • 4 
  • 5  1 

V= {Q,R,S,T}; weighted, directed

graph

4 5 8 9 10 6 10 4 12 8 Q S T R

#5 Draw the corresponding

adjacency list.