1. How to count V if the graph is stored in an EL?
We take all vertices of each rows, then comparing with collection of vertices which was checked. If that vertex has existed in the collection, we don’t count. So, it takes O(E*V) time complexity. It is not good, we can change our mind to use some bits memory to store this data.
2. How to count E if the graph is stored in an AM?
In this case, we go for each column of each row of the AM and then divide 2. It takes O(V2) time complexity.
3. How to enumerate neighbors of a vertex u if the graph is stored in an
EL? In this case, we go through all two times in the EL. First time for column ‘u’, second for ‘v’, if the u exist >>> we count. It takes O(E) to check.
4. How to check the existence of edge (u, v) if the graph is stored in an
EL? In this case, we just go to each row of the EL, then find out which row contains ‘u’ and ‘v’. It take O(E) time complexity.