Minimum Spanning Tree (Prim's Algorithm)

Objective

Given a connected graph, the objective of this system is to build a (any) minimum spanning tree of the graph using Prim's Algorithm.

Graph Color Codes

The table below, lists all the colors used in the graph, along with their interpretations.

Node/Edge Color Type
Unselected Node
Selected Node
Unselected Edge
Candidate Edge
Selected Edge
Incorrect Candidate Edge

Experiment Setup

In this system, you are provided with a connected graph. You can click on any node to select it. Candidate Edges can be clicked, to add those edge to the sub-graph. Clicking other nodes is not permitted after selecting a node.

Minimum Spanning Tree

A minimum spanning tree is a spanning tree of a graph, which has the minimum possible total edge weight.

Note :

You can reposition edges and nodes by dragging nodes if the labels are not visible due to overlapping.

Procedure

Initial: Selecting the first node

  1. Select the first node, to start building the spanning tree. The first node will be the root node of the spanning tree.

Growing the Minimum Spanning Tree

After selecting the first node, you will see the minimum spanning tree beside the graph. At this point the tree has just the one selected node. Now, you will observe that the edges connected to the selected node(s) are marked as "candidates" (See the color codes table).

  1. Select any of the minimum weighted candidate edges to add that edge to the minimum spanning tree.
  2. If all the nodes are added to the tree, the minimum spanning tree is complete and you will not see any candidate edges any more. Otherwise repear step 1.

Select any node to add it to the tree.

Graph
Minimum Spanning Tree