// File: /workspace/github_cpp_makefile_star2_O2/yogesh1q2w[P]Dynamic-Graph-Algorithms/MST.cpp
// Function: MST::delete_edge(int, int)
bool MST::delete_edge(int u, int v) {
	if(!vertices.count(u) || !vertices.count(v))
		return false;		//if u or v are absent in graph
	int lvl = level(u, v);
	if(lvl == -1)
		return false;
	if(!min_spf[0].cut(u, v)) {		//if not a tree edge
		remove_edge_level(u, v, lvl, false);
		return true;
	}
	
	remove_edge_level(u, v, lvl, true);

	for(int i = lvl; i >= 0; i--) {
		if(min_spf[i].size(u) > min_spf[i].size(v))
			swap(u, v);
		while(1) {
			int x = min_spf[i].get_adjacent(u, true);
			if(x == -1)
				break;
			while(!treeadj[i][x].empty()) {
				int y = (*treeadj[i][x].begin()).second;
				remove_edge_level(x, y, i, true);
				add_edge_level(x, y, i + 1, true);
				min_spf[i + 1].link(x, y); 
			}
		}

		bool ff = false;

		while(!ff) {
			int x = min_spf[i].get_adjacent(u, false);
			if(x == -1) 
				break;
			while(!adj[i][x].empty()) {
				int y = (*adj[i][x].begin()).second;//get y based on edge weights and not in any order as it comes from a priority queue
				if(min_spf[i].is_connected(y, v)) {
					for(int j = 0; j <= i; j++)
						min_spf[j].link(x, y);
					ff = true;
					remove_edge_level(x, y, i, false);
					add_edge_level(x, y, i, true);
					break;
				}
				else {
					remove_edge_level(x, y, i, false);
					add_edge_level(x, y, i + 1, false);
				}
			}
		}
		if(ff)
			break;
	}
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq -0x34(%rbp), %rax
movl %esi, (%rax)
movl %edx, -0x30(%rbp)
leaq 0x38(%rdi), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4ba8
testq %rax, %rax
je 0x728f
leaq -0x30(%rbp), %rsi
movq %r14, %rdi
callq 0x4ba8
testq %rax, %rax
je 0x728f
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
movq %rbx, %rdi
callq 0x6ea2
cmpl $-0x1, %eax
je 0x728f
movl %eax, %r14d
movq 0x68(%rbx), %rdi
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x2b82
movl -0x34(%rbp), %esi
movl -0x30(%rbp), %edx
testb %al, %al
je 0x7293
pushq $0x1
popq %r8
movq %rbx, %rdi
movl %r14d, %ecx
callq 0x6c22
movslq %r14d, %r13
leaq -0x2c(%rbp), %r15
movb $0x1, %al
testq %r13, %r13
js 0x72a3
imulq $0x118, %r13, %r12      # imm = 0x118
movq 0x68(%rbx), %rdi
addq %r12, %rdi
movl -0x34(%rbp), %esi
callq 0x2c82
movl %eax, %r14d
movq 0x68(%rbx), %rdi
movq %r12, -0x48(%rbp)
addq %r12, %rdi
movl -0x30(%rbp), %esi
callq 0x2c82
cmpl %eax, %r14d
jle 0x70cb
movl -0x34(%rbp), %eax
movl -0x30(%rbp), %ecx
movl %ecx, -0x34(%rbp)
movl %eax, -0x30(%rbp)
leaq 0x1(%r13), %rax
movq %r13, -0x40(%rbp)
imulq $0x38, %r13, %r13
movq %rax, -0x58(%rbp)
imulq $0x118, %rax, %r14      # imm = 0x118
movq 0x68(%rbx), %rdi
addq -0x48(%rbp), %rdi
movl -0x34(%rbp), %esi
pushq $0x1
popq %rdx
callq 0x2cb4
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0x7176
movq 0xd0(%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x7b30
cmpq $0x0, 0x28(%rax)
je 0x70e2
movq 0xd0(%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x7b30
movq 0x18(%rax), %rax
movl 0x24(%rax), %r12d
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movq -0x40(%rbp), %rcx
pushq $0x1
popq %r15
movl %r15d, %r8d
callq 0x6c22
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movq -0x58(%rbp), %rcx
movl %r15d, %r8d
leaq -0x2c(%rbp), %r15
callq 0x6a00
movq 0x68(%rbx), %rdi
addq %r14, %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x2a08
jmp 0x70fd
xorl %eax, %eax
movq -0x48(%rbp), %r14
testb $0x1, %al
jne 0x72a1
movl %eax, -0x4c(%rbp)
movq 0x68(%rbx), %rdi
addq %r14, %rdi
movl -0x34(%rbp), %esi
xorl %edx, %edx
callq 0x2cb4
movl %eax, -0x2c(%rbp)
cmpl $-0x1, %eax
je 0x7283
movq 0xb8(%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x7b30
cmpq $0x0, 0x28(%rax)
je 0x7219
movq 0xb8(%rbx), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x7b30
movq 0x18(%rax), %rax
movl 0x24(%rax), %r12d
movq 0x68(%rbx), %rdi
addq %r14, %rdi
movl -0x30(%rbp), %edx
movl %r12d, %esi
callq 0x2b0a
testb %al, %al
jne 0x7221
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movq -0x40(%rbp), %rcx
xorl %r8d, %r8d
callq 0x6c22
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movq -0x58(%rbp), %rcx
xorl %r8d, %r8d
callq 0x6a00
jmp 0x71a4
movl -0x4c(%rbp), %eax
jmp 0x717c
xorl %r14d, %r14d
xorl %r15d, %r15d
cmpq -0x40(%rbp), %r15
jg 0x724b
movq 0x68(%rbx), %rdi
addq %r14, %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x2a08
incq %r15
addq $0x118, %r14            # imm = 0x118
jmp 0x7227
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movq -0x40(%rbp), %r14
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x6c22
movl -0x2c(%rbp), %esi
movq %rbx, %rdi
movl %r12d, %edx
movl %r14d, %ecx
pushq $0x1
popq %r8
callq 0x6a00
movb $0x1, %al
leaq -0x2c(%rbp), %r15
jmp 0x7178
movq -0x40(%rbp), %r13
decq %r13
jmp 0x7083
xorl %eax, %eax
jmp 0x72a3
movq %rbx, %rdi
movl %r14d, %ecx
xorl %r8d, %r8d
callq 0x6c22
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq