“Modern” adjacency list with incidence containers
An extension to the Edge list graph data structure, where each vertex also stores a sequence of edges that are incident on it
- The edge sequence itself should have pointers to the incidence containers in which it is contained for efficiency
Note
This is the adjacency list type covered at The University of Sydney
Use a doubly linked list as the container for and for optimal time complexity
Using an array is easier but things like
removeEdge
will become due to increased deletion time complexity
Time complexities
Where is the # of vertices, is the # of edges
Operation | Complexity | Notes |
---|---|---|
Space | E list , V list , incidence list composed of edges, so | |
insertVertex(x) | Add to V sequence | |
insertEdge(u,v,x) | Add to E sequence, update incidence containers for 2 vertices | |
removeVertex(v) | Traverse vertex’s incidence container for incident edges to remove | |
removeEdge(e) | Remove self from its 2 incidence containers (pointers stored), remove from E | |
degree(v) | Track size of incidence container | |
incidentEdges(v) | Traverse incidence container to return each | |
getEdge(u,v) | Get degree of the 2 vertices, traverse incidence of smaller to check existence of edge | |
endVerticesOf(e) | Edge pointer given - return the relevant vertex pointers | |
opposite(v,e) | Edge pointer given - return other vertex | |
vertices() | Traverse V | |
edges() | Traverse E | |
numVertices() | Dependent on a counter variable | |
numEdges() | Dependent on a counter variable |
Directed graph information
See this link