// File: jkeys-ecg-nmsu[P]graph-with-search-algorithms/BFS.cpp
// Function: BFS(Graph&, Node&)
void BFS(Graph & g, Node & s) {
	queue<Node> q;
	
	g.resetAllDist();
	
	g.setDist(s, 0); //s is the root 
	q.push(s);
	
	while ( !q.empty() ) {
		Node u = q.front();
		q.pop();
		
		set<Node> uAdjNodes = g.getAdjNodes(u);
		
		//for every adjacent node v: (u)--->(v)
		for(set<Node>::iterator v = uAdjNodes.begin(); v != uAdjNodes.end(); v++) {
			if(g.dist(*v) == M_INFINITY) {		//if v has not been visited in BFS
				g.setDist(*v, g.dist(u) + 1);	//v.dist == u.dist + 1
				q.push(*v);						//push the adjacent node to back of the queue
			}
		} //end adjNodes loop
	} //end while
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x13890
movq -0x8(%rbp), %rdi
callq 0x6810
jmp 0x13637
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorps %xmm0, %xmm0
callq 0x5d50
jmp 0x13649
movq -0x10(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x138c0
jmp 0x13658
jmp 0x1365a
leaq -0x60(%rbp), %rdi
callq 0x138f0
movb %al, -0x139(%rbp)
jmp 0x1366b
movb -0x139(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1367c
jmp 0x1386b
leaq -0x60(%rbp), %rdi
callq 0x13910
movq %rax, -0x148(%rbp)
jmp 0x1368e
movq -0x148(%rbp), %rsi
leaq -0xf0(%rbp), %rdi
callq 0x2b50
jmp 0x136a3
leaq -0x60(%rbp), %rdi
callq 0x13930
jmp 0x136ae
movq -0x8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x62e0
movq %rax, -0x150(%rbp)
jmp 0x136c7
movq -0x150(%rbp), %rsi
leaq -0x120(%rbp), %rdi
callq 0x8750
jmp 0x136dc
leaq -0x120(%rbp), %rdi
callq 0x8780
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x87e0
movq %rax, -0x130(%rbp)
leaq -0x128(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x87b0
testb $0x1, %al
jne 0x1371e
jmp 0x13840
movq -0x8(%rbp), %rax
movq %rax, -0x160(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x8810
movq -0x160(%rbp), %rdi
movq %rax, %rsi
callq 0x5fe0
movsd %xmm0, -0x158(%rbp)
jmp 0x1374e
movsd -0x158(%rbp), %xmm0
movsd 0x690a(%rip), %xmm1     # 0x1a068
ucomisd %xmm1, %xmm0
jne 0x13824
jp 0x13824
movq -0x8(%rbp), %rax
movq %rax, -0x178(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x8810
movq %rax, -0x170(%rbp)
movq -0x8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x5fe0
movsd %xmm0, -0x168(%rbp)
jmp 0x137a6
movq -0x170(%rbp), %rsi
movq -0x178(%rbp), %rdi
movsd -0x168(%rbp), %xmm0
movsd 0x688c(%rip), %xmm1     # 0x1a050
addsd %xmm1, %xmm0
callq 0x5d50
jmp 0x137cf
leaq -0x128(%rbp), %rdi
callq 0x8810
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x138c0
jmp 0x137e9
jmp 0x13824
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1387d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
jmp 0x1385d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x3530
jmp 0x1385d
jmp 0x13826
leaq -0x128(%rbp), %rdi
xorl %esi, %esi
callq 0x8830
movq %rax, -0x138(%rbp)
jmp 0x136ef
leaq -0x120(%rbp), %rdi
callq 0x3530
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
jmp 0x1365a
leaq -0xf0(%rbp), %rdi
callq 0x2bd0
jmp 0x1387d
leaq -0x60(%rbp), %rdi
callq 0x13950
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x60(%rbp), %rdi
callq 0x13950
movq -0x68(%rbp), %rdi
callq 0x23e0
nop