# Traversal of the graph: DFS and BFS expansion trees

You can build a DFS spanning tree or a BFS spanning tree in many ways. It could require that the next advantage be traversed, it should be the cheapest available, if that helps you in some way or if you just want to do it. While you are using DFS or BFS, you will end up with an expansion tree.

However, if you want to always traverse the next cheapest edge among all possible options, "Queue: a c d b e h h k k i j k k" for BFS should be "Queue: a c d b e h k k i j l l", which is a supposed typo.

"Is this an MCST?" No, neither is a minimum-cost expansion tree, commonly referred to as a minimum expansion tree (MST). The DFS expansion tree, {(a, c), (c, h), (h, g), (g, f), (f, b), (b, k), (k, j), ( j, i), (i, l), (l, m), (m, e), (e, d)} could have a lower cost if (g, f) is replaced by (c, f). The BFS expansion tree, {(a, c), (a, d), (a, b), (a, e), (c, f), (c, h), (b, g), ( b, k), (e, m), (h, j), (k, l)} could have a lower cost if (b, g) is replaced by (h, g). As you can see, there is no guarantee that an MST can be obtained if you use a DFS or BFS.

In fact, for this particular graph, no matter how you perform BFS or DFS, you will not end up with an MST.