Adjacency lists and matrix
For adjacency lists (
- Returning the incident edges or adjacent vertices for a vertex
runs in time (size of the list) - Determining whether two vertices
and are adjacent can be performed by inspecting list for or that of . By choosing the smaller of the two, we get time.
For adjacency matrices (
- Determining adjacencies between pairs of vertices occurs in constant time (a single lookup operation)