// File: guitld[P]Graph-Algorithms/source/Graph.cpp
// Function: Graph::connected_components()
void Graph::connected_components(){

     // Defining structures for the algorithm
     vector <int> visitedNodes;
     vector <int> componentsSize;
     int numberOfComponents = 0;

     // Looping through the graph. If the current vertex is not marked as visited, then it belongs to a new component
     for (auto node : adj_lists){
          if (find(visitedNodes.begin(), visitedNodes.end(), node.first) == visitedNodes.end()){
               // Calls a DFS to mark new nodes
               DFS_Util_Connected_Components(node.first, visitedNodes, componentsSize);
               numberOfComponents++;
          }
     }

     // Sorting the components in descending order
     sort(componentsSize.begin(), componentsSize.end(), greater<int>());
     cout << numberOfComponents << endl;
     for (auto elem : componentsSize){
          cout << elem << endl;
     }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe8(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x5ca0
leaq -0x38(%rbp), %rdi
callq 0x5ca0
movq -0xe8(%rbp), %rax
movl $0x0, -0x3c(%rbp)
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x5970
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
callq 0x59a0
movq %rax, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x59d0
testb $0x1, %al
jne 0x4a6e
jmp 0x4b72
leaq -0x50(%rbp), %rdi
callq 0x5a00
movq %rax, %rsi
leaq -0x78(%rbp), %rdi
callq 0x5a30
jmp 0x4a85
leaq -0x20(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x61e0
movq -0xf8(%rbp), %rdi
movq %rax, -0x98(%rbp)
callq 0x6210
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
movq -0xa0(%rbp), %rsi
leaq -0x78(%rbp), %rdx
callq 0x6190
movq %rax, -0xf0(%rbp)
jmp 0x4acf
movq -0xf0(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x6210
movq %rax, -0xa8(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x6150
testb $0x1, %al
jne 0x4b06
jmp 0x4b5b
movq -0xe8(%rbp), %rdi
movl -0x78(%rbp), %esi
leaq -0x20(%rbp), %rdx
leaq -0x38(%rbp), %rcx
callq 0x4680
jmp 0x4b1f
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4b5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4c97
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x2a40
jmp 0x4c97
leaq -0x78(%rbp), %rdi
callq 0x2a40
leaq -0x50(%rbp), %rdi
callq 0x5b40
jmp 0x4a58
leaq -0x38(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x61e0
movq -0x100(%rbp), %rdi
movq %rax, -0xb0(%rbp)
callq 0x6210
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rdi
movq -0xb8(%rbp), %rsi
callq 0x63a0
jmp 0x4bb1
movl -0x3c(%rbp), %esi
movq 0x1840d(%rip), %rdi     # 0x1cfc8
callq 0x22b0
movq %rax, -0x108(%rbp)
jmp 0x4bc9
movq -0x108(%rbp), %rdi
movq 0x183e1(%rip), %rsi     # 0x1cfb8
callq 0x21d0
jmp 0x4bde
leaq -0x38(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x61e0
movq %rax, -0xd0(%rbp)
movq -0xc8(%rbp), %rdi
callq 0x6210
movq %rax, -0xd8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x63e0
testb $0x1, %al
jne 0x4c28
jmp 0x4c7c
leaq -0xd0(%rbp), %rdi
callq 0x6420
movl (%rax), %eax
movl %eax, -0xdc(%rbp)
movl -0xdc(%rbp), %esi
movq 0x1837f(%rip), %rdi     # 0x1cfc8
callq 0x22b0
movq %rax, -0x110(%rbp)
jmp 0x4c57
movq -0x110(%rbp), %rdi
movq 0x18353(%rip), %rsi     # 0x1cfb8
callq 0x21d0
jmp 0x4c6c
jmp 0x4c6e
leaq -0xd0(%rbp), %rdi
callq 0x6440
jmp 0x4c0f
leaq -0x38(%rbp), %rdi
callq 0x5f90
leaq -0x20(%rbp), %rdi
callq 0x5f90
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x5f90
leaq -0x20(%rbp), %rdi
callq 0x5f90
movq -0x80(%rbp), %rdi
callq 0x22c0
nopw %cs:(%rax,%rax)