// File: jkeys-ecg-nmsu[P]graph-with-search-algorithms/Kruskal.cpp
// Function: Kruskal_MST_djsets(Graph&)
Graph Kruskal_MST_djsets ( Graph & g) {	
	Graph r(g.num_nodes() + 1);
	r.copyNodes(g);
	r.copyEdges(g);
		
	make_set(g);
	
	vector<Edge> E = get_all_edges(g);
	
	// make_edge_heap(E);
	
	sort(E.begin(), E.end(), edge_heap_comp);
	
	// while(!E.empty()) {
	for(int i = 0; i != E.size(); i++) {
		// Edge e = cheapest_edge(E); //get cheapest edge and pop
		Edge e = E.at(i);
		Node u = g.getNode(e.u_id());
		Node v = g.getNode(e.v_id());
		
		if(find(g, u) != find(g,v)) {
			// cerr << "in djsets, sets are disjoint, edge: ";
			// e.print(r);			
			
			r.pushEdge(e);
			MST_union(g, u, v);
		}
	}
	
	return r; //MST is contained in m_edges_MST
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x278(%rbp)
movq %rdi, %rax
movq %rax, -0x280(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6100
movq -0x278(%rbp), %rdi
movl %eax, %esi
incl %esi
callq 0x3d50
movq -0x278(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6a10
jmp 0x17a23
movq -0x278(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6a80
jmp 0x17a35
movq -0x10(%rbp), %rdi
callq 0x171e0
jmp 0x17a40
movq -0x10(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x16d30
jmp 0x17a4f
leaq -0x40(%rbp), %rdi
movq %rdi, -0x288(%rbp)
callq 0xc6d0
movq -0x288(%rbp), %rdi
movq %rax, -0x48(%rbp)
callq 0xc550
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0xf72(%rip), %rdx      # 0x16b10
callq 0x18010
jmp 0x17a89
movl $0x0, -0x54(%rbp)
movslq -0x54(%rbp), %rax
movq %rax, -0x290(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7f40
movq %rax, %rcx
movq -0x290(%rbp), %rax
cmpq %rcx, %rax
je 0x17cfa
movslq -0x54(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x7f60
movq %rax, -0x298(%rbp)
jmp 0x17acd
movq -0x298(%rbp), %rax
movups (%rax), %xmm0
movaps %xmm0, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xeec0
movl %eax, -0x29c(%rbp)
jmp 0x17af7
movq -0x2a8(%rbp), %rdi
movl -0x29c(%rbp), %eax
movslq %eax, %rsi
callq 0x5040
movq %rax, -0x2b0(%rbp)
jmp 0x17b15
movq -0x2b0(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2b50
jmp 0x17b2a
movq -0x10(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xeed0
movl %eax, -0x2b4(%rbp)
jmp 0x17b46
movq -0x2c0(%rbp), %rdi
movl -0x2b4(%rbp), %eax
movslq %eax, %rsi
callq 0x5040
movq %rax, -0x2c8(%rbp)
jmp 0x17b64
movq -0x2c8(%rbp), %rsi
leaq -0x170(%rbp), %rdi
callq 0x2b50
jmp 0x17b79
movq -0x10(%rbp), %rax
movq %rax, -0x2d0(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x2b50
jmp 0x17b99
movq -0x2d0(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x172c0
movl %eax, -0x2d4(%rbp)
jmp 0x17bb4
movq -0x10(%rbp), %rax
movq %rax, -0x2e0(%rbp)
leaq -0x270(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x2b50
jmp 0x17bd4
movq -0x2e0(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x172c0
movl %eax, -0x2e4(%rbp)
jmp 0x17bef
leaq -0x270(%rbp), %rdi
callq 0x2bd0
leaq -0x1f0(%rbp), %rdi
callq 0x2bd0
movl -0x2e4(%rbp), %ecx
movl -0x2d4(%rbp), %eax
cmpl %ecx, %eax
je 0x17cba
movq -0x278(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x5f00
jmp 0x17c2d
movq -0x10(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
leaq -0x170(%rbp), %rdx
callq 0x173d0
jmp 0x17c46
jmp 0x17cba
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17d36
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17d0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17cec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17ce0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x17cac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x2bd0
leaq -0x1f0(%rbp), %rdi
callq 0x2bd0
jmp 0x17ce0
leaq -0x170(%rbp), %rdi
callq 0x2bd0
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x17a90
leaq -0x170(%rbp), %rdi
callq 0x2bd0
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
jmp 0x17d0f
movb $0x1, -0x11(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2c50
testb $0x1, -0x11(%rbp)
jne 0x17d26
jmp 0x17d1a
leaq -0x40(%rbp), %rdi
callq 0x2c50
jmp 0x17d36
movq -0x278(%rbp), %rdi
callq 0x2c00
movq -0x280(%rbp), %rax
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
movq -0x278(%rbp), %rdi
callq 0x2c00
movq -0x20(%rbp), %rdi
callq 0x23e0
nopl (%rax,%rax)