Understanding spanning trees
Before we go ahead and implement the pseudo code and the code, let's take some time to understand what spanning trees are and how we can employ them to simplify the problems as stated previously.
A spanning tree within a graph is a series of edges that can connect all the nodes without any cycles within them. By saying that, it is obvious that there can be more than one spanning tree for any given graph. In terms of our example, it makes more sense now that we want to generate the minimum spanning tree (MST), that is, the spanning tree in which the combined edge weight is the minimum.
However, how do we generate the spanning tree and make sure that it has the minimum value? The solution, although not quite obvious, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access