I'm trying to modify this algorithm: http://demonstrations.wolfram.com/ConnectingTownsUsingKruskalsAlgorithm/
The thing is that I want to receive a Graph (declared outside, with all its vertex, edges and weights) in the Kruskal's function and start from there, using maybe a WeightedAdjacencyMatrix[G] and sort the weights and returning them. It's just a practice I want to do, because I'm learning Mathematica, so I'm still a noob with this. To be more specific with my question, I just want to know where and how I can replace parts from the code, with the things I mentioned above. This is my idea, of course without the Kruskal's implementation:
G = Graph[{a \[UndirectedEdge] b, a \[UndirectedEdge] d,
a \[UndirectedEdge] f, b \[UndirectedEdge] c,
b \[UndirectedEdge] d, b \[UndirectedEdge] e,
c \[UndirectedEdge] e, c \[UndirectedEdge] g,
d \[UndirectedEdge] e, d \[UndirectedEdge] f,
d \[UndirectedEdge] g, e \[UndirectedEdge] g,
f \[UndirectedEdge] g},
EdgeWeight -> {5, 6, 7, 5, 5, 4, 3, 3, 2, 2, 3, 1, 2},
VertexLabels -> "Name", ImagePadding -> 10]
Kruskal[G]