Source code for MST