// File: GAStudyGroup[P]GPX2/src/cross/gpx/sources/GPX2Support.cpp
// Function: GPX2Support::findPartition(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, Node*, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, Node*>>>&)
vector<string> GPX2Support::findPartition(const string nodeOne, GPX2Structs::NodeMap &unitedGraph)
{ //Given a value, this method will use nodeOne as a root which will be the first point of the search in Gu', when it finds the partition in which the node is contained the method will return a vector with the ids of the citites that compose the partition

    Node* root; // node to be verified
    vector<string> idAlreadyVisited; // visited nodes list
    deque<string> nextToVisit; // list of the next nodes to visit
    vector<string> partition;

    bool notAlreadyVisited{ false };
    bool notToVisit{ false };
    bool notCut{ false };

    nextToVisit.push_back(nodeOne); // first node to be visited

    while (!nextToVisit.empty()) { // while there are nodes to visit
        root = unitedGraph[nextToVisit.front()]; // node in which the BFS will start
        nextToVisit.pop_front(); // Removes the node from the list
        partition.push_back(root->getId()); // inserts the node in the partition
        idAlreadyVisited.push_back(root->getId()); // Nodes in the "Already visited" list

        for (Node::node n : root->getEdges()) { //goes through the connected edges
            notAlreadyVisited = find(idAlreadyVisited.begin(), idAlreadyVisited.end(), n.first) == idAlreadyVisited.end(); // checks if the edge was visited
            notToVisit = find(nextToVisit.begin(), nextToVisit.end(), n.first) == nextToVisit.end(); //checks if it isn't in the list to be visited
            notCut = n.second != 0; // checks if the edge was "cut"
            if (notAlreadyVisited && notToVisit && notCut) { // case if all conditions are satisfied
                nextToVisit.push_back(
                    n.first); // puts in the list of the next to be visited
            }
        }
    }
    return (partition); // returns a vector with the partition
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %rsi, 0x48(%rsp)
movq %rdi, 0x50(%rsp)
movq %rdi, %rax
movq %rax, 0x58(%rsp)
movq %rdi, 0x210(%rsp)
movq %rsi, 0x208(%rsp)
movq %rdx, 0x200(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x1e3e0
leaq 0x190(%rsp), %rdi
callq 0x70690
jmp 0x6c94d
movq 0x50(%rsp), %rdi
movb $0x0, 0x183(%rsp)
callq 0x1e3e0
movq 0x48(%rsp), %rsi
movb $0x0, 0x182(%rsp)
movb $0x0, 0x181(%rsp)
movb $0x0, 0x180(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x706a0
jmp 0x6c98b
jmp 0x6c98d
leaq 0x190(%rsp), %rdi
callq 0x70700
xorb $-0x1, %al
testb $0x1, %al
jne 0x6c9a5
jmp 0x6cd29
movq 0x200(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x70970
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x60c60
movq %rax, 0x40(%rsp)
jmp 0x6c9d3
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1f8(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x709a0
movq 0x1f8(%rsp), %rsi
leaq 0x160(%rsp), %rdi
callq 0x66190
jmp 0x6ca07
movq 0x50(%rsp), %rdi
leaq 0x160(%rsp), %rsi
callq 0x1e3f0
jmp 0x6ca1b
leaq 0x160(%rsp), %rdi
callq 0x6988
movq 0x1f8(%rsp), %rsi
leaq 0x140(%rsp), %rdi
callq 0x66190
jmp 0x6ca3f
leaq 0x1e0(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x1e3f0
jmp 0x6ca56
leaq 0x140(%rsp), %rdi
callq 0x6988
movq 0x1f8(%rsp), %rdi
callq 0x661c0
movq %rax, 0x30(%rsp)
jmp 0x6ca77
movq 0x30(%rsp), %rax
movq %rax, 0x138(%rsp)
movq 0x138(%rsp), %rdi
callq 0x60f80
movq %rax, 0x130(%rsp)
movq 0x138(%rsp), %rdi
callq 0x60fb0
movq %rax, 0x128(%rsp)
leaq 0x130(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x60fe0
testb $0x1, %al
jne 0x6cacc
jmp 0x6cd24
leaq 0x130(%rsp), %rdi
callq 0x61020
movq %rax, %rsi
leaq 0x100(%rsp), %rdi
callq 0x61030
jmp 0x6caeb
leaq 0x1e0(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x1e310
movq 0x20(%rsp), %rdi
movq %rax, 0xf0(%rsp)
callq 0x1e340
movq %rax, 0xe8(%rsp)
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
leaq 0x100(%rsp), %rdx
callq 0x49c90
movq %rax, 0x28(%rsp)
jmp 0x6cb3b
movq 0x28(%rsp), %rax
movq %rax, 0xf8(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x1e340
movq %rax, 0xe0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
callq 0x55c20
movb %al, 0x182(%rsp)
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x10(%rsp)
leaq 0x190(%rsp), %rsi
movq %rsi, 0x8(%rsp)
callq 0x70860
movq 0x8(%rsp), %rsi
leaq 0x80(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x70890
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0xc0(%rsp), %rdi
leaq 0x100(%rsp), %rcx
callq 0x707e0
jmp 0x6cbd0
leaq 0x60(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x70890
leaq 0xc0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x707c0
andb $0x1, %al
movb %al, 0x181(%rsp)
movsd 0x120(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %al
setp %cl
orb %cl, %al
andb $0x1, %al
movb %al, 0x180(%rsp)
testb $0x1, 0x182(%rsp)
je 0x6cd05
testb $0x1, 0x181(%rsp)
je 0x6cd05
testb $0x1, 0x180(%rsp)
je 0x6cd05
leaq 0x190(%rsp), %rdi
leaq 0x100(%rsp), %rsi
callq 0x706a0
jmp 0x6cc5f
jmp 0x6cd05
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x6cd83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0x6cd6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x6988
jmp 0x6cd6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x140(%rsp), %rdi
callq 0x6988
jmp 0x6cd6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x610b0
jmp 0x6cd6c
leaq 0x100(%rsp), %rdi
callq 0x610b0
leaq 0x130(%rsp), %rdi
callq 0x610c0
jmp 0x6caae
jmp 0x6c98d
movb $0x1, 0x183(%rsp)
testb $0x1, 0x183(%rsp)
jne 0x6cd45
movq 0x50(%rsp), %rdi
callq 0xa2c0
leaq 0x190(%rsp), %rdi
callq 0x70900
leaq 0x1e0(%rsp), %rdi
callq 0xa2c0
movq 0x58(%rsp), %rax
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x50(%rsp), %rdi
callq 0xa2c0
leaq 0x190(%rsp), %rdi
callq 0x70900
leaq 0x1e0(%rsp), %rdi
callq 0xa2c0
movq 0x188(%rsp), %rdi
callq 0x6850
nopl (%rax)