public SparseGraph <GraphNode, GraphEdge> GetMST() { // essentially, make a new graph with the spanning tree list SparseGraph <GraphNode, GraphEdge> g = new SparseGraph <GraphNode, GraphEdge>(); foreach (GraphNode n in graph.Nodes) { g.AddNode(new GraphNode(g.nextNodeIndex)); } //add all the edges from the other spanning tree foreach (GraphEdge e in spanningTree) { g.AddDoubleEdge(new GraphEdge(e.from, e.to, e.cost)); } return(g); }