This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: o Space: O( ) o Run time • Is edge (x,y) in graph? O(1) • Find/List all neighbors of x O(n) o Appropriate for dense graphs o For sparse graphs, waste a lot of space storing false values o Instead, store the neighbors for each of the vertices in a LL 1. Adjacency LL o Space: • n+2e • # of array spots=n • # of nodes= 2e undirected E directed • O(n+e) o Run time: • Is edge (x,y) in graph? O(min(n,e)) • Find/List all neighbors of x O(min(n,e)) o Much better for sparse graphs (generally considered default since graphs are usually more sparse)...
View Full Document
- Spring '09
- Graph Theory, Computational complexity theory, sparse graphs, Adjacency matrix/table storage, vs Sparse Graphs