I think J must come before D because the distance from F and J is 1 and between F and D is 2.

One way to think about breadth-first search is to imagine water flowing from F. It first reaches nodes at distance one, then at distance two, etc. The order in which nodes at the same distance are listed (e.g., J, E, C) is probably not important.

To write an algorithm, one considers a queue (first in, first out) of nodes. In the beginning the queue has only F. There is also a sequence of nodes already visited; initially it is empty. At each step, one takes out a node from the end of the queue, mark it as visited, and pushes all its neighbors that have not been visited and are not already in the queue into the start of the queue. This continues until the queue is empty.

So a possible sequence of queue contents and the list of visited nodes is

Code:

Queue Visited
---------------+--------
F |
J E C | F
D B I J E | F C
D B I J | F C E
D B I | F C E J
D B | F C E J I
...

I'll let you finish from here. Feel free to post your version for checking.