1. ## Breadth-frist transversal

I understand how to list each transversal when each node has at most
2 lines( coming in or out) but how not sure about a graph where a node has
more than 2 line connected to it. For example consider this graph :

Can you help me for instance list the transversal route using breadth-first search
starting at node F.

One way I tried and got this : F-C-E-D-I-G-H-B-A-J, but am not sure if its correct. I am not sure how to transverse through the graph, say starting at node F, using the breadth-first-search. Any Help?

2. F-C-E-D-I-G-H-B-A-J
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.