Finding a Minimum Spanning Tree using QGIS
There is an already existing tool in processing plugin in
GRASS -> Vector -> v.net.spanningtree
You will need to specify the vector line layer and the nodes ( optional ) and in advanced parameters add the type of the geometry of the output layer
and that's it, you'll get a new vector layer with the spanning tree
You may also rely on the 'Minimum Spanning Tree' plugin of QGIS 3.x.
The paper Geo-MST: A geographical minimum spanning tree plugin for QGIS discusses the plugin thoroughly.