| | | | | |

Adjacency List Representation

  • Vertices v0 ... vn -1
  • Vector V of lists
  • V[i] = the adjacency list for vertex vi
    • List of vertices reachable in one step from vertex vi
    • Lists other end of each edge counted by out(vi)
  • Digraph::AddEdge(x,y) { V[x].PushBack(y); }
  • Ungraph::AddEdge(x,y) { V[x].PushBack(y); V[y].PushBack(x); }
  • Storage size = Θ(eSize + vSize) = Θ(eSize + n)
  • Edge access time = Θ(outDegree(vertex))
    • Random access to adjacency list
    • Sequential search in the adjacency list
  • Amortized edge access time = Θ(1) for sparse graphs

| | Top of Page | 12. Graphs and Digraphs [under revision] - 6 of 12