// File: 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
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x58(%rbp)
addq $0x38, %rdi
leaq -0x14(%rbp), %rsi
callq 0xad30
cmpq $0x0, %rax
je 0x13cf4
movq -0x58(%rbp), %rdi
addq $0x38, %rdi
leaq -0x18(%rbp), %rsi
callq 0xad30
cmpq $0x0, %rax
jne 0x13cfd
movb $0x0, -0x1(%rbp)
jmp 0x1406c
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x13ad0
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x13d1e
movb $0x0, -0x1(%rbp)
jmp 0x1406c
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaad0
movq %rax, %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x3140
testb $0x1, %al
jne 0x13d5f
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
xorl %r8d, %r8d
callq 0x136e0
movb $0x1, -0x1(%rbp)
jmp 0x1406c
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
movl $0x1, %r8d
callq 0x136e0
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jl 0x14068
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
movslq -0x20(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x3270
movq -0x58(%rbp), %rdi
movl %eax, -0x5c(%rbp)
addq $0x68, %rdi
movslq -0x20(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x3270
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jle 0x13dd8
leaq -0x14(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0xa9b0
jmp 0x13dda
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
movslq -0x20(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x14(%rbp), %esi
movl $0x1, %edx
callq 0x32d0
movl %eax, -0x24(%rbp)
cmpl $-0x1, -0x24(%rbp)
jne 0x13e09
jmp 0x13eda
jmp 0x13e0b
movq -0x58(%rbp), %rdi
addq $0xd0, %rdi
movslq -0x20(%rbp), %rsi
callq 0x14a10
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x14a30
movq %rax, %rdi
callq 0x14bb0
xorb $-0x1, %al
testb $0x1, %al
jne 0x13e3e
jmp 0x13ed5
movq -0x58(%rbp), %rdi
addq $0xd0, %rdi
movslq -0x20(%rbp), %rsi
callq 0x14a10
movq %rax, %rdi
leaq -0x24(%rbp), %rsi
callq 0x14a30
movq %rax, %rdi
callq 0x14bd0
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x14c00
movq -0x58(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0x1, %r8d
callq 0x136e0
movq -0x58(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
movl $0x1, %r8d
callq 0x13420
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
movl -0x20(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
callq 0x2f30
jmp 0x13e0b
jmp 0x13dda
movb $0x0, -0x31(%rbp)
movb -0x31(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x13eec
jmp 0x14050
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
movslq -0x20(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x14(%rbp), %esi
xorl %edx, %edx
callq 0x32d0
movl %eax, -0x38(%rbp)
cmpl $-0x1, -0x38(%rbp)
jne 0x13f18
jmp 0x14050
jmp 0x13f1a
movq -0x58(%rbp), %rdi
addq $0xb8, %rdi
movslq -0x20(%rbp), %rsi
callq 0x14a10
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x14a30
movq %rax, %rdi
callq 0x14bb0
xorb $-0x1, %al
testb $0x1, %al
jne 0x13f4d
jmp 0x1404b
movq -0x58(%rbp), %rdi
addq $0xb8, %rdi
movslq -0x20(%rbp), %rsi
callq 0x14a10
movq %rax, %rdi
leaq -0x38(%rbp), %rsi
callq 0x14a30
movq %rax, %rdi
callq 0x14bd0
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x14c00
movq -0x58(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x3c(%rbp)
addq $0x68, %rdi
movslq -0x20(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x3c(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x3070
testb $0x1, %al
jne 0x13fad
jmp 0x14019
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jg 0x13fe6
movq -0x58(%rbp), %rdi
addq $0x68, %rdi
movslq -0x4c(%rbp), %rsi
callq 0xaad0
movq %rax, %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
callq 0x2f30
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x13fb4
movq -0x58(%rbp), %rdi
movb $0x1, -0x31(%rbp)
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
xorl %r8d, %r8d
callq 0x136e0
movq -0x58(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
movl $0x1, %r8d
callq 0x13420
jmp 0x1404b
movq -0x58(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
xorl %r8d, %r8d
callq 0x136e0
movq -0x58(%rbp), %rdi
movl -0x38(%rbp), %esi
movl -0x3c(%rbp), %edx
movl -0x20(%rbp), %ecx
addl $0x1, %ecx
xorl %r8d, %r8d
callq 0x13420
jmp 0x13f1a
jmp 0x13ede
testb $0x1, -0x31(%rbp)
je 0x14058
jmp 0x14068
jmp 0x1405a
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x13d7d
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)