Graph representations
How we represent a directed graph or undirected graph in an algorithm can effect the run time of an algorithm.
Bellow are some common ways to do this:
Data structure | Space complexity | Time to check connection | Time to find neighbours |
---|---|---|---|
Adjacency list | |||
Adjacency matrix | |||
Edge list |