Complexities of Graph Operations
Let's discuss the performance of the two graph representation approaches.
We'll cover the following...
We'll cover the following...
Time Complexities
Below, you can find the time complexities for the 4 basic graph methods.
Note that in this table, V means the total number of vertices, and E means the total number of edges in the Graph.
Operation | Adjacency List | Adjacency Matrix |
---|---|---|
Add Vertex | O(1) | O(V2) |
Remove Vertex | O(V+E) |