Minimum Spanning Tree

Just off the top of my head (and if I’m understanding the problem correctly), what you want to do is create the subgraph with those array elements as edges, and then use something like dfs to pull out all the paths. That’s going to be very expensive, I think, and I don’t have a quick solution in code for this right now. (The new 1.4.0 / 2.0.0 code should make this easier but it’s not ready for prime time yet.)