Prim, Kruskal Why? only undirected graph?

In our example, there is just one MSA possible. That is s \rightarrow b \rightarrow a. But running Kruskal’s algorithm, we first of all select a \rightarrow b:

Since this edge is not contained in our MSA it is impossible to construct one from the Kruskal algorithm in this example.

3.2. Prim

For the Prim algorithm, we have a similar setup:

This time the only possible MSA is s \rightarrow a \rightarrow b. Prim’s algorithm starts at a random node, in this case, s. It then takes the edge with the lowest edge connected to s, which is the node to b:

Since the edge, s \rightarrow b is not contained in the only MSA that the following steps won’t generate an MSA for this example.

Last updated