This project demonstrates **Prim's algorithm**, a method of finding the minimum spanning tree of a graph.

## Story

Maurice runs an online radio station. His original idea was to stream the audio from a single web server. This was easy to set up and initially worked very well.

Unfortunately, as his channel grew, so did the bill from his telco. His rickety server didn't fare much better, as not a week went by before it crashed during peak hour. A flash flood of traffic from Reddit was the last straw. Something had to be done.

The problem was his server sent an individual copy of the podcast to every listener, a strategy that worked with two or three listeners but did not scale to 100. He could have easily upgraded his bandwidth or his computer, but he was already scraping a living and did not want to spend more. So the only viable solution was to share the burden using a peer-to-peer system.

Here's where the **minimum spanning tree** comes in. Given a graph of all the connections, we can help Maurice figure out a way of distributing the load, so that everyone is connected as efficiently as possible. To calculate this, we use – you guessed it – Prim's algorithm.

## Algorithm

Not all connections are created equal – some have a higher latency (delay or lag) than others, which is indicated by a number next to each edge. This algorithm takes this into account and chooses the path with minimal cost.

1. Add Maurice's server to the tree. This is our starting point.

2. Find the edge with the minimum cost that connects a node *inside* the tree to a node *outside*, and add it to the tree.

3. If all nodes are part of the tree, we're done! Otherwise, repeat from step 2.