// File: /workspace/github_cpp_makefile_star2_O2/yogesh1q2w[P]Dynamic-Graph-Algorithms/main.cpp
// Function: test(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void test(int func,string file) {
	if(func == 1) {
		ifstream ifs(file, ifstream::in);
		ofstream ofs("timefile.txt", ofstream::out | ios::app);
		int V,E;
		ifs >> V >> E;
		connectivity g = connectivity();
		long update = 0,query = 0;
		double querytime = 0, updatetime = 0;
		for(int i = 0; i < V; i++)
			g.add_vertex(i);

		//cout << V <<", " << E << endl;
		for(int i = 0; i < E; i++) {
			int u, v;
			ifs >> u >> v;
			//cout << u << "==="<<v << endl;
			g.add_edge(u, v);

		}
		
		for(int i = 0; i < ITER; i++) {
			int qtype = rand() % 3;
			//cout << qtype << endl;
			if(qtype == 0) {
				int u = rand() % V;
				int v = rand() % V;
				auto t1 = chrono::high_resolution_clock::now();
				g.add_edge(u, v);
				auto t2 = chrono::high_resolution_clock::now();
				updatetime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				update++;
			}
			else if(qtype == 1) {
				int u = rand() % V;
				int v = rand() % V;
				auto t1 = chrono::high_resolution_clock::now();
				g.delete_edge(u, v);
				auto t2 = chrono::high_resolution_clock::now();
				updatetime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				update++;
			}
			else if(qtype == 2) {
				int u = rand() % V;
				int v = rand() % V;
				auto t1 = chrono::high_resolution_clock::now();
				bool res = g.is_connected(u, v);
				auto t2 = chrono::high_resolution_clock::now();
				querytime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				query++;
			}
		}
		ofs << updatetime/(update * 1.0) << " " << querytime/(query * 1.0) << endl;
	}
	else if(func == 2) {
		ifstream ifs(file, ifstream::in);
		ofstream ofs("timefile.txt", ofstream::out | ios::app);
		int V,E;
		ifs >> V >> E;
		MST g = MST();
		long update = 0,query = 0;
		double querytime = 0, updatetime = 0;
		for(int i = 0; i < V; i++)
			g.add_vertex(i);

		//cout << V <<", " << E << endl;
		for(int i = 0; i < E; i++) {
			int u, v, wt;
			ifs >> u >> v >> wt;
			//cout << u << "==="<<v << endl;
			g.add_edge(u, v, wt);

		}
		g.build_static_MST();
		
		for(int i = 0; i < ITER; i++) {
			int qtype = rand() % 2;
			//cout << qtype << endl;
			if(qtype == 0) {
				int u = rand() % V;
				int v = rand() % V;
				auto t1 = chrono::high_resolution_clock::now();
				g.delete_edge(u, v);
				auto t2 = chrono::high_resolution_clock::now();
				updatetime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				update++;
			}
			else if(qtype == 1) {
				auto t1 = chrono::high_resolution_clock::now();
				set <pair<pair<int,int>,int>> res = g.find_MST();
				auto t2 = chrono::high_resolution_clock::now();
				querytime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				query++;
			}
		}
		ofs << updatetime/(update * 1.0) << " " << querytime/(query * 1.0) << endl;
	}
	else if(func == 3) {
		ifstream ifs(file, ifstream::in);
		ofstream ofs("timefile.txt", ofstream::out | ios::app);
		int V,E;
		ifs >> V >> E;
		SPT g = SPT();
		long update = 0,query = 0;
		double querytime = 0, updatetime = 0;
		for(int i = 0; i < V; i++)
			g.add_vertex(i);

		// cout << V <<", " << E << endl;
		for(int i = 0; i < E; i++) {
			int u, v, wt;	int c = 0;
			ifs >> u >> v >> wt;
			//cout << u << "===" << v << endl;
			g.add_edge(u, v, wt);

		}

		g.source = rand() % V;
		g.build_static_SPT();
		
		for(int i = 0; i < ITER; i++) {
			int qtype = rand() % 2;
			//cout << qtype << endl;
			if(qtype == 0) {
				int u = rand() % V;
				int v = rand() % V;
				int wt = rand() % CHNGWT;
				auto t1 = chrono::high_resolution_clock::now();
				g.change_weight(u, v, wt);
				auto t2 = chrono::high_resolution_clock::now();
				updatetime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				update++;
			}
			else if(qtype == 1) {
				auto t1 = chrono::high_resolution_clock::now();
				vector<pair<int,int>> res =  g.find_SPT();
				auto t2 = chrono::high_resolution_clock::now();
				querytime +=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
				query++;
			}
		}
		// cout << querytime << " " << query << endl;
		ofs << updatetime/(update * 1.0) << " " << querytime/(query * 1.0) << endl;
	}
	else {
		cout << "Wrong choice.. Enter 1,2 or 3" << endl;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x598, %rsp            # imm = 0x598
pushq $0x1
popq %r15
cmpl $0x3, %edi
je 0xb3ab
cmpl $0x2, %edi
je 0xb2ad
cmpl $0x1, %edi
jne 0xb49f
leaq -0x3c0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2210
leaq 0xe92(%rip), %rsi       # 0xc08b
leaq -0x5c0(%rbp), %rdi
pushq $0x11
popq %rdx
callq 0x2180
leaq -0x3c0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x2100
leaq -0x2c(%rbp), %rsi
movq %rax, %rdi
callq 0x2100
leaq -0x1b0(%rbp), %r15
leaq -0x1b8(%rbp), %rbx
xorl %r14d, %r14d
movl $0xa0, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
movq %r15, 0x18(%rbx)
movq %r15, 0x20(%rbx)
leaq -0x110(%rbp), %rax
xorpd %xmm0, %xmm0
movupd %xmm0, -0x80(%rax)
movupd %xmm0, -0x70(%rax)
movupd %xmm0, -0x60(%rax)
movupd %xmm0, -0x50(%rax)
movupd %xmm0, -0x40(%rax)
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movupd %xmm0, -0x8(%rax)
cmpl -0x98(%rbp), %r14d
jge 0xb587
movq %rbx, %rdi
movl %r14d, %esi
callq 0x4350
incl %r14d
jmp 0xb290
leaq -0x3c0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2210
leaq 0xdc8(%rip), %rsi       # 0xc08b
leaq -0x5c0(%rbp), %rdi
pushq $0x11
popq %rdx
callq 0x2180
leaq -0x3c0(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2100
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x2100
leaq -0x198(%rbp), %rdi
xorl %ebx, %ebx
movl $0xf0, %edx
xorl %esi, %esi
callq 0x20d0
leaq -0x188(%rbp), %rax
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, %ecx       # imm = 0x3F800000
movl %ecx, -0x10(%rax)
movupd %xmm0, -0x8(%rax)
leaq -0x178(%rbp), %rax
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
leaq -0x108(%rbp), %rax
movupd %xmm0, -0x50(%rax)
movupd %xmm0, -0x40(%rax)
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl %ecx, -0x10(%rax)
leaq -0xa0(%rbp), %rax
movupd %xmm0, -0x70(%rax)
movupd %xmm0, -0x60(%rax)
movupd %xmm0, -0x50(%rax)
movupd %xmm0, -0x40(%rax)
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl %ecx, -0x10(%rax)
movupd %xmm0, -0x8(%rax)
leaq -0x1b8(%rbp), %r14
cmpl -0x2c(%rbp), %ebx
jge 0xb4cb
movq %r14, %rdi
movl %ebx, %esi
callq 0x68d8
incl %ebx
jmp 0xb394
leaq -0x3c0(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x2210
leaq 0xcca(%rip), %rsi       # 0xc08b
leaq -0x5c0(%rbp), %rdi
pushq $0x11
popq %rdx
callq 0x2180
leaq -0x3c0(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x2100
leaq -0x48(%rbp), %rsi
movq %rax, %rdi
callq 0x2100
leaq -0x1b8(%rbp), %rbx
xorl %r14d, %r14d
movl $0xd0, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x20d0
leaq -0x180(%rbp), %rax
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
xorpd %xmm0, %xmm0
movupd %xmm0, -0x20(%rax)
movl $0x3f800000, %ecx       # imm = 0x3F800000
movl %ecx, -0x10(%rax)
movupd %xmm0, -0x8(%rax)
leaq -0x170(%rbp), %rax
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
leaq -0x118(%rbp), %rax
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl %ecx, -0x10(%rax)
movupd %xmm0, -0x8(%rax)
leaq -0xe0(%rbp), %rax
movq %rax, -0x30(%rax)
movq %r15, -0x28(%rax)
movupd %xmm0, -0x20(%rax)
movl %ecx, -0x10(%rax)
movupd %xmm0, -0x8(%rax)
movupd %xmm0, 0x8(%rax)
movupd %xmm0, 0x18(%rax)
movupd %xmm0, 0x28(%rax)
cmpl -0x2c(%rbp), %r14d
jge 0xb529
movq %rbx, %rdi
movl %r14d, %esi
callq 0x9134
incl %r14d
jmp 0xb485
movq 0x7b2a(%rip), %rdi      # 0x12fd0
leaq 0xbed(%rip), %rsi       # 0xc09a
callq 0x2150
movq %rax, %rdi
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20b0
xorl %ebx, %ebx
leaq -0x98(%rbp), %r14
leaq -0x44(%rbp), %r15
leaq -0x54(%rbp), %r12
leaq -0x1b8(%rbp), %r13
cmpl -0x48(%rbp), %ebx
jge 0xb75b
leaq -0x3c0(%rbp), %rdi
movq %r14, %rsi
callq 0x2100
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
movq %r12, %rsi
callq 0x2100
movl -0x98(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x54(%rbp), %ecx
movq %r13, %rdi
callq 0x6eee
incl %ebx
jmp 0xb4e3
xorl %ebx, %ebx
leaq -0x98(%rbp), %r14
leaq -0x44(%rbp), %r15
leaq -0x54(%rbp), %r12
leaq -0x1b8(%rbp), %r13
cmpl -0x48(%rbp), %ebx
jge 0xb84f
leaq -0x3c0(%rbp), %rdi
movq %r14, %rsi
callq 0x2100
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movq %rax, %rdi
movq %r12, %rsi
callq 0x2100
movl -0x98(%rbp), %esi
movl -0x44(%rbp), %edx
movl -0x54(%rbp), %ecx
movq %r13, %rdi
callq 0x91da
incl %ebx
jmp 0xb541
xorl %r13d, %r13d
leaq -0x3c0(%rbp), %rbx
leaq -0x48(%rbp), %r14
leaq -0x44(%rbp), %r15
leaq -0x1b8(%rbp), %r12
cmpl -0x2c(%rbp), %r13d
jge 0xb5cf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2100
movq %rax, %rdi
movq %r15, %rsi
callq 0x2100
movl -0x48(%rbp), %esi
movl -0x44(%rbp), %edx
movq %r12, %rdi
callq 0x4740
incl %r13d
jmp 0xb5a0
xorpd %xmm0, %xmm0
movsd %xmm0, -0x38(%rbp)
pushq $0x5
popq %rbx
movq $0x0, -0x50(%rbp)
movsd %xmm0, -0x40(%rbp)
xorl %r13d, %r13d
subl $0x1, %ebx
jb 0xb702
callq 0x2060
cltd
pushq $0x3
popq %rcx
idivl %ecx
cmpl $0x2, %edx
je 0xb6a6
cmpl $0x1, %edx
je 0xb64b
testl %edx, %edx
jne 0xb5eb
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r15d
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r12d
callq 0x2030
movq %rax, %r14
leaq -0x1b8(%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x4740
jmp 0xb683
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r15d
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r12d
callq 0x2030
movq %rax, %r14
leaq -0x1b8(%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x47c4
callq 0x2030
subq %r14, %rax
cvtsi2sd %rax, %xmm0
movsd -0x38(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
incq %r13
jmp 0xb5eb
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r15d
callq 0x2060
cltd
idivl -0x98(%rbp)
movl %edx, %r12d
callq 0x2030
movq %rax, %r14
leaq -0x1b8(%rbp), %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x4a78
callq 0x2030
subq %r14, %rax
cvtsi2sd %rax, %xmm0
movsd -0x40(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
incq -0x50(%rbp)
jmp 0xb5eb
cvtsi2sd %r13, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
leaq -0x5c0(%rbp), %rdi
callq 0x2200
leaq 0x975(%rip), %rsi       # 0xc098
movq %rax, %rdi
callq 0x2150
cvtsi2sdq -0x50(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
callq 0x20b0
leaq -0x1b8(%rbp), %rdi
callq 0xbb8e
jmp 0xba07
leaq -0x1b8(%rbp), %rdi
callq 0x7378
xorpd %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
pushq $0x5
popq %rbx
movq $0x0, -0x38(%rbp)
pushq $0x2
popq %r14
leaq -0x98(%rbp), %r12
movq $0x0, -0x68(%rbp)
movsd %xmm0, -0x40(%rbp)
subl $0x1, %ebx
jb 0xb95c
callq 0x2060
cltd
idivl %r14d
cmpl $0x1, %edx
je 0xb80c
testl %edx, %edx
jne 0xb793
movq -0x38(%rbp), %r14
callq 0x2060
cltd
idivl -0x2c(%rbp)
movl %edx, -0x60(%rbp)
callq 0x2060
cltd
idivl -0x2c(%rbp)
movl %edx, %r13d
callq 0x2030
movq %rax, %r15
leaq -0x1b8(%rbp), %rdi
movl -0x60(%rbp), %esi
movl %r13d, %edx
callq 0x6fec
callq 0x2030
subq %r15, %rax
cvtsi2sd %rax, %xmm0
movsd -0x40(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
incq %r14
movq %r14, -0x38(%rbp)
pushq $0x2
popq %r14
jmp 0xb793
callq 0x2030
movq %rax, %r15
movq %r12, %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x72b2
callq 0x2030
subq %r15, %rax
cvtsi2sd %rax, %xmm0
movsd -0x50(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x50(%rbp)
incq -0x68(%rbp)
movq %r12, %rdi
callq 0x782a
jmp 0xb793
callq 0x2060
cltd
idivl -0x2c(%rbp)
leaq -0x1b8(%rbp), %rdi
movl %edx, (%rdi)
callq 0x928c
xorpd %xmm0, %xmm0
movsd %xmm0, -0x40(%rbp)
pushq $0x5
popq %r14
xorl %r13d, %r13d
pushq $0x2
popq %r12
leaq -0x98(%rbp), %rbx
movq $0x0, -0x60(%rbp)
movsd %xmm0, -0x38(%rbp)
subl $0x1, %r14d
jb 0xb9b3
callq 0x2060
cltd
idivl %r12d
cmpl $0x1, %edx
je 0xb919
testl %edx, %edx
jne 0xb88e
callq 0x2060
cltd
idivl -0x2c(%rbp)
movl %edx, %r12d
callq 0x2060
cltd
idivl -0x2c(%rbp)
movl %edx, -0x50(%rbp)
callq 0x2060
cltd
pushq $0x64
popq %rcx
idivl %ecx
movl %edx, %ebx
callq 0x2030
movq %rax, %r15
leaq -0x1b8(%rbp), %rdi
movl %r12d, %esi
movl -0x50(%rbp), %edx
movl %ebx, %ecx
callq 0x942c
callq 0x2030
subq %r15, %rax
cvtsi2sd %rax, %xmm0
movsd -0x38(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x38(%rbp)
incq %r13
pushq $0x2
popq %r12
leaq -0x98(%rbp), %rbx
jmp 0xb88e
callq 0x2030
movq %rax, %r15
movq %rbx, %rdi
leaq -0x1b8(%rbp), %rsi
callq 0xa1c6
callq 0x2030
subq %r15, %rax
cvtsi2sd %rax, %xmm0
movsd -0x40(%rbp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, -0x40(%rbp)
incq -0x60(%rbp)
movq %rbx, %rdi
callq 0x7880
jmp 0xb88e
cvtsi2sdq -0x38(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
leaq -0x5c0(%rbp), %rdi
callq 0x2200
leaq 0x71a(%rip), %rsi       # 0xc098
movq %rax, %rdi
callq 0x2150
cvtsi2sdq -0x68(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
callq 0x20b0
leaq -0x1b8(%rbp), %rdi
callq 0xbbca
jmp 0xba07
cvtsi2sd %r13, %xmm1
movsd -0x38(%rbp), %xmm0
divsd %xmm1, %xmm0
leaq -0x5c0(%rbp), %rdi
callq 0x2200
leaq 0x6c4(%rip), %rsi       # 0xc098
movq %rax, %rdi
callq 0x2150
cvtsi2sdq -0x60(%rbp), %xmm1
movsd -0x40(%rbp), %xmm0
divsd %xmm1, %xmm0
movq %rax, %rdi
callq 0x2200
movq %rax, %rdi
callq 0x20b0
leaq -0x1b8(%rbp), %rdi
callq 0xbc24
leaq -0x5c0(%rbp), %rdi
callq 0x21e0
leaq -0x3c0(%rbp), %rdi
callq 0x2050
addq $0x598, %rsp            # imm = 0x598
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xba35
jmp 0xba35
movq %rax, %rbx
jmp 0xba9a
jmp 0xba3e
jmp 0xba3e
movq %rax, %rbx
jmp 0xba8e
jmp 0xba5d
jmp 0xba6e
jmp 0xba7f
jmp 0xba5d
jmp 0xba5d
jmp 0xba5d
jmp 0xba6e
jmp 0xba7f
jmp 0xba6e
jmp 0xba7f
jmp 0xba5d
jmp 0xba6e
jmp 0xba7f
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0xbb8e
jmp 0xba8e
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0xbc24
jmp 0xba8e
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0xbbca
leaq -0x5c0(%rbp), %rdi
callq 0x21e0
leaq -0x3c0(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x2240