Lecture 1-18-17
Graphs
- Care about form of storage because > constant factor
- Representations
- Adjacency matrix
- Adjacency lists
Time complexity
- Matrix: O(1)
- Adjacency list: O(n)
- also can be considered “degree” of vertex
- faster for finding Euler cycles
- Space:
Graph algorithms
- Ak[x, y] = number of paths from x to y of length k
- Shortest path (weighted, unweighted)
- Traveling salesman
- BFS
- DFS
- Need to use adjacency lists
Homework