// File: /workspace/github_cpp_makefile_star2_O1/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
movl %edx, %r13d
movl %esi, %r14d
movq %rdi, %r15
movq 0x48(%rdi), %rcx
leaq 0x40(%rdi), %rax
movq %rax, %rdx
testq %rcx, %rcx
je 0x6f28
movq %rcx, %rsi
movq %rax, %rdx
xorl %edi, %edi
cmpl %r14d, 0x20(%rsi)
setl %dil
cmovgeq %rsi, %rdx
movq 0x10(%rsi,%rdi,8), %rsi
testq %rsi, %rsi
jne 0x6f10
movq %rax, %rsi
cmpq %rax, %rdx
je 0x6f3b
cmpl %r14d, 0x20(%rdx)
cmovgq %rax, %rdx
movq %rdx, %rsi
cmpq %rax, %rsi
je 0x7245
movq %rax, %rdx
testq %rcx, %rcx
je 0x6f67
movq %rax, %rdx
xorl %esi, %esi
cmpl %r13d, 0x20(%rcx)
setl %sil
cmovgeq %rcx, %rdx
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0x6f4f
movq %rax, %rcx
cmpq %rax, %rdx
je 0x6f7a
cmpl %r13d, 0x20(%rdx)
cmovgq %rax, %rdx
movq %rdx, %rcx
cmpq %rax, %rcx
je 0x7245
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x6d2a
movl %eax, %ebx
cmpl $-0x1, %eax
setne %al
je 0x7247
movq 0x68(%r15), %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x2d82
testb %al, %al
je 0x7256
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x6a9a
movb $0x1, %al
testl %ebx, %ebx
js 0x7247
movl %r14d, -0x3c(%rbp)
leal 0x1(%rbx), %r14d
movl %ebx, %ecx
movq %rcx, -0x48(%rbp)
movl %r13d, -0x34(%rbp)
imulq $0x118, %rcx, %rbx      # imm = 0x118
movq 0x68(%r15), %rdi
addq %rbx, %rdi
movl -0x3c(%rbp), %r12d
movl %r12d, %esi
callq 0x2ee8
movl %eax, -0x30(%rbp)
movq 0x68(%r15), %rdi
movq %rbx, -0x58(%rbp)
addq %rbx, %rdi
movl -0x34(%rbp), %ebx
movl %ebx, %esi
callq 0x2ee8
cmpl %eax, -0x30(%rbp)
cmovgl %r12d, %r13d
cmovgl %ebx, %r12d
movl %r12d, -0x3c(%rbp)
leaq -0x38(%rbp), %r12
movq -0x48(%rbp), %rax
leaq 0x1(%rax), %rbx
movl %r13d, -0x4c(%rbp)
movq 0x68(%r15), %rdi
addq -0x58(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0x1, %edx
callq 0x2f20
movl %eax, -0x38(%rbp)
cmpl $-0x1, %eax
je 0x70ed
movl %eax, -0x34(%rbp)
imulq $0x38, -0x48(%rbp), %r13
movq 0xd0(%r15), %rdi
addq %r13, %rdi
movq %r12, %rsi
callq 0x7bfa
cmpq $0x0, 0x28(%rax)
je 0x70df
movq 0xd0(%r15), %rdi
addq %r13, %rdi
movq %r12, %rsi
callq 0x7bfa
movq 0x18(%rax), %rax
movl 0x24(%rax), %r12d
movl -0x38(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movq -0x48(%rbp), %rcx
movl $0x1, %r8d
callq 0x6a9a
movl -0x38(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x678a
imulq $0x118, %rbx, %rdi      # imm = 0x118
addq 0x68(%r15), %rdi
movl -0x38(%rbp), %esi
movl %r12d, %edx
leaq -0x38(%rbp), %r12
callq 0x2be4
jmp 0x7062
cmpl $-0x1, -0x34(%rbp)
movl -0x4c(%rbp), %r13d
jne 0x7039
movq -0x48(%rbp), %rbx
leal 0x1(%rbx), %eax
movl %eax, -0x60(%rbp)
movl $0x0, -0x30(%rbp)
movb $0x1, %al
leaq -0x2c(%rbp), %r12
testb $0x1, -0x30(%rbp)
jne 0x722d
movq 0x68(%r15), %rdi
addq -0x58(%rbp), %rdi
movl -0x3c(%rbp), %esi
xorl %edx, %edx
callq 0x2f20
movl %eax, -0x2c(%rbp)
movl %eax, -0x5c(%rbp)
cmpl $-0x1, %eax
je 0x7221
imulq $0x38, %rbx, %rbx
movq 0xb8(%r15), %rdi
addq %rbx, %rdi
movq %r12, %rsi
callq 0x7bfa
cmpq $0x0, 0x28(%rax)
je 0x721d
addq 0xb8(%r15), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x7bfa
movq 0x18(%rax), %rax
movl 0x24(%rax), %r12d
movq 0x68(%r15), %rdi
addq -0x58(%rbp), %rdi
movl %r12d, %esi
movl %r13d, %edx
callq 0x2cf2
movb %al, -0x34(%rbp)
testb %al, %al
je 0x71e2
xorl %r13d, %r13d
xorl %ebx, %ebx
movq 0x68(%r15), %rdi
addq %r13, %rdi
movl -0x2c(%rbp), %esi
movl %r12d, %edx
callq 0x2be4
incq %rbx
addq $0x118, %r13            # imm = 0x118
cmpq %rbx, %r14
jne 0x7189
movl -0x2c(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movq -0x48(%rbp), %rbx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x6a9a
movl -0x2c(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movl %ebx, %ecx
movl $0x1, %r8d
callq 0x678a
movb $0x1, %al
movl %eax, -0x30(%rbp)
movl -0x4c(%rbp), %r13d
jmp 0x720d
movl -0x2c(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movq -0x48(%rbp), %rbx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x6a9a
movl -0x2c(%rbp), %esi
movq %r15, %rdi
movl %r12d, %edx
movl -0x60(%rbp), %ecx
xorl %r8d, %r8d
callq 0x678a
cmpb $0x0, -0x34(%rbp)
leaq -0x2c(%rbp), %r12
je 0x712f
jmp 0x7221
movq -0x48(%rbp), %rbx
cmpl $-0x1, -0x5c(%rbp)
movb $0x1, %al
jne 0x7104
testb $0x1, -0x30(%rbp)
jne 0x7247
leaq -0x1(%rbx), %rcx
decq %r14
testq %rbx, %rbx
jg 0x6fe0
jmp 0x7247
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
movl %r14d, %esi
movl %r13d, %edx
movl %ebx, %ecx
xorl %r8d, %r8d
callq 0x6a9a
movb $0x1, %al
jmp 0x7247
nop