CS 415, Section 002 Sonoma State University Spring, 2022
 
Algorithm Analysis
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College

Worksheet:  Graph Representations and Graph Traversals

Adjacency Matrices and Lists

    Consider the following adjacency matrix S for a weighted, directed graph. (Note: 0 means there is no edge.)

    A B C D E F G
    A 0 10 6 4 0 7 0
    B 10 0 9 0 11 0 18
    C 6 9 0 1 1 0 0
    D 4 0 1 0 1 2 0
    E 0 11 1 1 0 0 14
    F 7 0 0 2 0 0 15
    G 0 18 0 0 14 15 0
    1. Draw a picture of the graph represented by this adjacency matrix S without the weights.

    2. Is this graph directed or undirected? Explain.

    3. List the vertices in depth-first order beginning with vertex A. When you have a choice among vertices, pick them in alphabetical order.

    4. List the vertices in breadth-first order beginning with vertex A. Again, when you have a choice among vertices, pick them in alphabetical order.

A graph Specified by Sets

Problems 5 and 6 are based on the following graph. (Note that 0 means there is no edge.)