Draw your graph:
()
start = input(start)
visited = []
for(i = 0 to
Graph.numVertices)
visited[i] =
false
visited[start] = true
q = []
q.push(start)
while(length(q) != 0)
queueElement = q.shift()
neighbours =
Graph.getNeighboursOf(queueElement)
for(x = 0 to
length(neighbours))
nb = neighbours[x]
if(!visited[nb])
visited[nb] =
true
q.push(nb)
---------------------
| SHORT EXPLANATION |
---------------------
1. Visit the first vertex
2. Find all vertices this vertex has a connection to
3. Visit each of those vertices and push them onto the
queue
4. Take the next vertex from the queue
5. Repeat steps 2 - 4 until the queue is empty