Mark As Completed Discussion

Due to the fact that an edge list is really just an array, the only way to find something in this array is by iterating through it.

For example, if we wanted to see if vertex 1 was connected to vertex 2, we'd need to iterate through the previous array and look for the existence of a pair [1,2] or [2,1].

This is fine for this specific graph since it only has three vertices and three edges. But as you can imagine, having to iterate through a much larger array would increase complexity.

Checking to see if a particular edge existed in a large array isn't guaranteed to have a sense of order, and the edge could be at the very end of the list. Additionally, there may not be any edge at all, and we'd still have to iterate through the whole thing to check for it. This would take linear time, O(E) (E being the number of edges) to get it done.

Please find the implementation of an edge list attached.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment