Tutorial 9

Graph basics

Terminology: vertices

Alt text

Paths

Alt text

Cycle

Subgraph

Spanning subgraph

Connected graph

Trees and forests

Free (unrooted) tree

Forest

Alt text

Spanning trees and forests

Spanning Tree

Spanning Forest

Alt text

Properties

Density

Edge list

Adjacency map structure

List stores each vertex

Alt text

Adjacency matrix structure

Alt text

Performance

Alt text

Depth first search: Algorithm

Start at a vertex, add it to the stack and mark it as explored

  1. Remove vertex V from the stack
  2. Traverse to vertex W along an unexplored edge that is connected to vertex V.
  1. Push V to the stack. Go to step 2 using vertex W.
  2. Repeat Steps 2 & 3 until there are no unexplored edges. Go to Step 1. Repeat until the stack is empty

Process:

  1. Remove vertex V from the queue, visit all vertices connected to V.
  1. Mark edge as:
  1. Repeat steps 1 & 2 until the queue is empty

Digraphs

Reachability

Strong connectivity

Each vertex can reach all other vertices

Strongly connected Component

Subgraph where each vertex can reach all other vertices

Alt text

Transitive Closure

Alt text

Topological orger and Directed Acyclic Graphs

Graph before Graph after
Alt text Alt text