// File: dtsaras[P]GCW/./hypergraph.hpp
// Function: buildSeedSet(HyperGraph&, std::vector<int, std::allocator<int>>&, unsigned int, int, std::vector<double, std::allocator<double>>&)
void buildSeedSet(HyperGraph & hg, vector<int> & seeds, unsigned int n, int k, vector<double> &degree)
{	
	long long i;
	unsigned int j,l,maxInd;
	vector<int> e, nList;

	vector<int> nodeDegree(n,0);
	vector<int> indx(n,0);
	for (j = 0; j < n; ++j){
		indx[j] = j;
		nodeDegree[j] = hg.getNode(j+1).size();
	}

	InfCost<int> hd(&nodeDegree[0]);
	MappedHeap<InfCost<int> > heap(indx,hd);
	long long numEdge = hg.getNumEdge();

	// check if an edge is removed
	vector<bool> edgeMark(numEdge, false);
	vector<bool> nodeMark(n+1, true);
	
	double totalCost = 0;

	i=1;
	// building each seed at a time
	while(totalCost < k && !heap.empty()){
		maxInd = heap.pop()+1;
		nodeMark[maxInd] = false;

		totalCost++;

		e = hg.getNode(maxInd);
		
		degree[i] = degree[i-1]+nodeDegree[maxInd-1];
		
		seeds.push_back(maxInd);
		for (j = 0; j < e.size(); ++j){
			if (edgeMark[e[j]]){
				continue;
			}
	
			nList = hg.getEdge(e[j]);
			for (l = 0; l < nList.size(); ++l){
				nodeDegree[nList[l]-1]--;
				if (nodeMark[nList[l]]){
					heap.heapify(nList[l]-1);
				}
			}
			edgeMark[e[j]] = true;
		}
		i++;
	}

	vector<int>().swap(nodeDegree);
	vector<int>().swap(e);
	vector<int>().swap(nList);
	vector<int>().swap(indx);
	vector<bool>().swap(edgeMark);
}

// Assembly:
subq $0x328, %rsp            # imm = 0x328
movq %rdi, 0x320(%rsp)
movq %rsi, 0x318(%rsp)
movl %edx, 0x314(%rsp)
movl %ecx, 0x310(%rsp)
movq %r8, 0x308(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0xe2d0
leaq 0x2c0(%rsp), %rdi
callq 0xe2d0
movl 0x314(%rsp), %eax
movq %rax, 0xd0(%rsp)
movl $0x0, 0x2a4(%rsp)
leaq 0x2a3(%rsp), %rdi
movq %rdi, 0xd8(%rsp)
callq 0xe180
movq 0xd0(%rsp), %rsi
movq 0xd8(%rsp), %rcx
leaq 0x2a8(%rsp), %rdi
leaq 0x2a4(%rsp), %rdx
callq 0xe190
jmp 0x4e4d
leaq 0x2a3(%rsp), %rdi
callq 0xe210
movl 0x314(%rsp), %eax
movq %rax, 0xc0(%rsp)
movl $0x0, 0x274(%rsp)
leaq 0x273(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0xe180
movq 0xc0(%rsp), %rsi
movq 0xc8(%rsp), %rcx
leaq 0x278(%rsp), %rdi
leaq 0x274(%rsp), %rdx
callq 0xe190
jmp 0x4eb0
leaq 0x273(%rsp), %rdi
callq 0xe210
movl $0x0, 0x2fc(%rsp)
movl 0x2fc(%rsp), %eax
cmpl 0x314(%rsp), %eax
jae 0x4fd2
movl 0x2fc(%rsp), %eax
movl %eax, %esi
movl %esi, %eax
movl %eax, 0xb4(%rsp)
leaq 0x278(%rsp), %rdi
callq 0xe3b0
movl 0xb4(%rsp), %ecx
movl %ecx, (%rax)
movq 0x320(%rsp), %rdi
movl 0x2fc(%rsp), %esi
incl %esi
callq 0x1f9d0
movq %rax, 0xb8(%rsp)
jmp 0x4f24
movq 0xb8(%rsp), %rdi
callq 0xe3d0
movl %eax, 0xb0(%rsp)
movl 0x2fc(%rsp), %eax
movl %eax, %esi
leaq 0x2a8(%rsp), %rdi
callq 0xe3b0
movl 0xb0(%rsp), %ecx
movl %ecx, (%rax)
movl 0x2fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2fc(%rsp)
jmp 0x4ec8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x2a3(%rsp), %rdi
callq 0xe210
jmp 0x57b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x273(%rsp), %rdi
callq 0xe210
jmp 0x57ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x579e
xorl %eax, %eax
movl %eax, %esi
leaq 0x2a8(%rsp), %rdi
callq 0xe3b0
movq %rax, %rsi
leaq 0x268(%rsp), %rdi
callq 0xe3f0
jmp 0x4ff5
movq 0x268(%rsp), %rax
movq %rax, 0x220(%rsp)
movq 0x220(%rsp), %rdx
leaq 0x228(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0xe410
jmp 0x5024
movq 0x320(%rsp), %rdi
callq 0x1fa00
movl %eax, 0xac(%rsp)
jmp 0x503a
movl 0xac(%rsp), %eax
cltq
movq %rax, 0x218(%rsp)
movq 0x218(%rsp), %rax
movq %rax, 0x98(%rsp)
movb $0x0, 0x1ef(%rsp)
leaq 0x1ee(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xe220
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rcx
leaq 0x1f0(%rsp), %rdi
leaq 0x1ef(%rsp), %rdx
callq 0xe230
jmp 0x509f
leaq 0x1ee(%rsp), %rdi
callq 0xe2b0
movl 0x314(%rsp), %eax
incl %eax
movq %rax, 0x88(%rsp)
movb $0x1, 0x1bf(%rsp)
leaq 0x1be(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xe220
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rcx
leaq 0x1c0(%rsp), %rdi
leaq 0x1bf(%rsp), %rdx
callq 0xe230
jmp 0x5101
leaq 0x1be(%rsp), %rdi
callq 0xe2b0
xorps %xmm0, %xmm0
movsd %xmm0, 0x1b0(%rsp)
movq $0x1, 0x300(%rsp)
movsd 0x1b0(%rsp), %xmm1
cvtsi2sdl 0x310(%rsp), %xmm0
xorl %eax, %eax
ucomisd %xmm1, %xmm0
movb %al, 0x87(%rsp)
jbe 0x516d
leaq 0x228(%rsp), %rdi
callq 0xe660
movb %al, 0x86(%rsp)
jmp 0x515d
movb 0x86(%rsp), %al
xorb $-0x1, %al
movb %al, 0x87(%rsp)
movb 0x87(%rsp), %al
testb $0x1, %al
jne 0x517d
jmp 0x55d2
leaq 0x228(%rsp), %rdi
callq 0xe680
movl %eax, 0x80(%rsp)
jmp 0x5193
movl 0x80(%rsp), %eax
incl %eax
movl %eax, 0x2f4(%rsp)
movl 0x2f4(%rsp), %eax
movl %eax, %esi
leaq 0x1c0(%rsp), %rdi
callq 0xe790
movq %rdx, 0x70(%rsp)
movq %rax, 0x78(%rsp)
jmp 0x51c5
movq 0x70(%rsp), %rax
movq 0x78(%rsp), %rcx
movq %rcx, 0x1a0(%rsp)
movq %rax, 0x1a8(%rsp)
leaq 0x1a0(%rsp), %rdi
xorl %esi, %esi
callq 0xe7f0
movsd 0x1b0(%rsp), %xmm0
movsd 0x2ce09(%rip), %xmm1    # 0x32008
addsd %xmm1, %xmm0
movsd %xmm0, 0x1b0(%rsp)
movq 0x320(%rsp), %rdi
movl 0x2f4(%rsp), %esi
callq 0x1f9d0
movq %rax, 0x68(%rsp)
jmp 0x5227
movq 0x68(%rsp), %rsi
leaq 0x2d8(%rsp), %rdi
callq 0xe840
jmp 0x523b
movq 0x308(%rsp), %rdi
movq 0x300(%rsp), %rsi
decq %rsi
callq 0xeb00
movsd (%rax), %xmm0
movsd %xmm0, 0x58(%rsp)
movl 0x2f4(%rsp), %eax
decl %eax
movl %eax, %esi
leaq 0x2a8(%rsp), %rdi
callq 0xe3b0
movsd 0x58(%rsp), %xmm0
cvtsi2sdl (%rax), %xmm1
addsd %xmm1, %xmm0
movsd %xmm0, 0x60(%rsp)
movq 0x308(%rsp), %rdi
movq 0x300(%rsp), %rsi
callq 0xeb00
movsd 0x60(%rsp), %xmm0
movsd %xmm0, (%rax)
movq 0x318(%rsp), %rdi
movl 0x2f4(%rsp), %eax
movl %eax, 0x19c(%rsp)
leaq 0x19c(%rsp), %rsi
callq 0xeb20
jmp 0x52cd
movl $0x0, 0x2fc(%rsp)
movl 0x2fc(%rsp), %eax
movq %rax, 0x50(%rsp)
leaq 0x2d8(%rsp), %rdi
callq 0xe3d0
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jae 0x55b9
movl 0x2fc(%rsp), %eax
movl %eax, %esi
leaq 0x2d8(%rsp), %rdi
callq 0xe3b0
movslq (%rax), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xe790
movq %rdx, 0x40(%rsp)
movq %rax, 0x48(%rsp)
jmp 0x5334
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rcx, 0x188(%rsp)
movq %rax, 0x190(%rsp)
leaq 0x188(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x5364
jmp 0x53f4
jmp 0x55a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
jmp 0x5791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x1ee(%rsp), %rdi
callq 0xe2b0
jmp 0x5791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x1be(%rsp), %rdi
callq 0xe2b0
jmp 0x5784
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x298(%rsp)
movl %eax, 0x294(%rsp)
leaq 0x1c0(%rsp), %rdi
callq 0xe3a0
jmp 0x5784
movq 0x320(%rsp), %rax
movq %rax, 0x30(%rsp)
movl 0x2fc(%rsp), %eax
movl %eax, %esi
leaq 0x2d8(%rsp), %rdi
callq 0xe3b0
movq 0x30(%rsp), %rdi
movl (%rax), %esi
callq 0x1f970
movq %rax, 0x38(%rsp)
jmp 0x542a
movq 0x38(%rsp), %rsi
leaq 0x2c0(%rsp), %rdi
callq 0xe840
jmp 0x543e
movl $0x0, 0x2f8(%rsp)
movl 0x2f8(%rsp), %eax
movq %rax, 0x28(%rsp)
leaq 0x2c0(%rsp), %rdi
callq 0xe3d0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x5547
movl 0x2f8(%rsp), %eax
movl %eax, %esi
leaq 0x2c0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0xe3b0
movl (%rax), %eax
decl %eax
movslq %eax, %rsi
leaq 0x2a8(%rsp), %rdi
callq 0xe3b0
movq 0x10(%rsp), %rdi
movl (%rax), %ecx
decl %ecx
movl %ecx, (%rax)
movl 0x2f8(%rsp), %eax
movl %eax, %esi
callq 0xe3b0
movslq (%rax), %rsi
leaq 0x1c0(%rsp), %rdi
callq 0xe790
movq %rdx, 0x18(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x54d7
movq 0x18(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x178(%rsp)
movq %rax, 0x180(%rsp)
leaq 0x178(%rsp), %rdi
callq 0xeb50
testb $0x1, %al
jne 0x5504
jmp 0x552f
movl 0x2f8(%rsp), %eax
movl %eax, %esi
leaq 0x2c0(%rsp), %rdi
callq 0xe3b0
movl (%rax), %esi
decl %esi
leaq 0x228(%rsp), %rdi
callq 0xeb80
jmp 0x552d
jmp 0x552f
jmp 0x5531
movl 0x2f8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2f8(%rsp)
jmp 0x5449
movl 0x2fc(%rsp), %eax
movl %eax, %esi
leaq 0x2d8(%rsp), %rdi
callq 0xe3b0
movslq (%rax), %rsi
leaq 0x1f0(%rsp), %rdi
callq 0xe790
movq %rdx, (%rsp)
movq %rax, 0x8(%rsp)
jmp 0x5578
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x168(%rsp)
movq %rax, 0x170(%rsp)
leaq 0x168(%rsp), %rdi
movl $0x1, %esi
callq 0xe7f0
movl 0x2fc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2fc(%rsp)
jmp 0x52d8
movq 0x300(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x300(%rsp)
jmp 0x5126
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4210
leaq 0x150(%rsp), %rdi
callq 0xe2d0
leaq 0x150(%rsp), %rdi
leaq 0x2a8(%rsp), %rsi
callq 0xebe0
leaq 0x150(%rsp), %rdi
callq 0xe2e0
leaq 0x138(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4210
leaq 0x138(%rsp), %rdi
callq 0xe2d0
leaq 0x138(%rsp), %rdi
leaq 0x2d8(%rsp), %rsi
callq 0xebe0
leaq 0x138(%rsp), %rdi
callq 0xe2e0
leaq 0x120(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4210
leaq 0x120(%rsp), %rdi
callq 0xe2d0
leaq 0x120(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0xebe0
leaq 0x120(%rsp), %rdi
callq 0xe2e0
leaq 0x108(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4210
leaq 0x108(%rsp), %rdi
callq 0xe2d0
leaq 0x108(%rsp), %rdi
leaq 0x278(%rsp), %rsi
callq 0xebe0
leaq 0x108(%rsp), %rdi
callq 0xe2e0
leaq 0xe0(%rsp), %rdi
xorl %esi, %esi
movl $0x28, %edx
callq 0x4210
leaq 0xe0(%rsp), %rdi
callq 0xec40
leaq 0xe0(%rsp), %rdi
leaq 0x1f0(%rsp), %rsi
callq 0xec50
leaq 0xe0(%rsp), %rdi
callq 0xe3a0
leaq 0x1c0(%rsp), %rdi
callq 0xe3a0
leaq 0x1f0(%rsp), %rdi
callq 0xe3a0
leaq 0x228(%rsp), %rdi
callq 0xecb0
leaq 0x278(%rsp), %rdi
callq 0xe2e0
leaq 0x2a8(%rsp), %rdi
callq 0xe2e0
leaq 0x2c0(%rsp), %rdi
callq 0xe2e0
leaq 0x2d8(%rsp), %rdi
callq 0xe2e0
addq $0x328, %rsp            # imm = 0x328
retq
leaq 0x1f0(%rsp), %rdi
callq 0xe3a0
leaq 0x228(%rsp), %rdi
callq 0xecb0
leaq 0x278(%rsp), %rdi
callq 0xe2e0
leaq 0x2a8(%rsp), %rdi
callq 0xe2e0
leaq 0x2c0(%rsp), %rdi
callq 0xe2e0
leaq 0x2d8(%rsp), %rdi
callq 0xe2e0
movq 0x298(%rsp), %rdi
callq 0x4690
nop