What is better, adjacency lists or adjacency matrices for graph problems in C++?
It depends on the problem. Adjacency Matrix Uses O(n^2) memory It is fast to lookup and check for presence or absence of a specific edge between any two nodes O(1) It is slow to iterate over all edges It is slow to add/delete a node; a complex operation O(n^2) It is fast to add a … Read more