// File: /workspace/github_cpp_makefile_star2_O3/riyadparvez[P]louvain-method/graph.cpp
// Function: Graph::Graph(char*, int)
Graph::Graph(char *filename, int type) {
  ifstream finput;
  finput.open(filename,fstream::in);
  set<int> s; 
  int nb_links=0;

  while (!finput.eof()) {
    unsigned int src, dest;
    double weight=1.;

    if (type==WEIGHTED) {
      finput >> src >> dest >> weight;
    } else {
      finput >> src >> dest;
    }
    
    if (finput) {
      if (links.size()<=max(src,dest)+1) {
        links.resize(max(src,dest)+1);
      }
      
      links[src].push_back(make_pair(dest,weight));
      if (src!=dest)
        links[dest].push_back(make_pair(src,weight));
      s.insert(src);
      s.insert(dest);
      nb_links++;
    }
  }
  //copy(s.begin(), s.end(), nodes.begin());
  copy(s.begin(), s.end(), std::back_inserter(nodes));
  sort(nodes.begin(), nodes.end());
  finput.close();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x258, %rsp            # imm = 0x258
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rdi), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
leaq 0x50(%rsp), %rdi
callq 0x21c0
leaq 0x50(%rsp), %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0x20f0
leaq 0x28(%rsp), %rsi
movl $0x0, (%rsi)
xorl %eax, %eax
movq %rax, 0x8(%rsi)
movq %rsi, 0x10(%rsi)
movq %rsi, 0x18(%rsi)
movq %rax, 0x20(%rsi)
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x2, 0x70(%rsp,%rax)
movq %rsi, %rdi
jne 0x262b
movq %r12, 0x10(%rsp)
leaq 0x50(%rsp), %r12
leaq 0x4(%rsp), %r13
movq %rsp, %r14
leaq 0x8(%rsp), %r15
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x18(%rsp)
testl %ebp, %ebp
je 0x2509
movq %r12, %rdi
movq %r13, %rsi
callq 0x22a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x22a0
jmp 0x252c
movq %r12, %rdi
movq %r13, %rsi
callq 0x22a0
movq %rax, %rdi
movq %r14, %rsi
callq 0x22a0
movq %rax, %rdi
leaq 0x18(%rsp), %rsi
callq 0x2100
movq 0x50(%rsp), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0x70(%rsp,%rcx)
jne 0x260d
movq (%rbx), %rax
movq 0x8(%rbx), %rdi
subq %rax, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdi
movl 0x4(%rsp), %edx
movl (%rsp), %ecx
cmpl %ecx, %edx
movl %ecx, %esi
cmoval %edx, %esi
incl %esi
cmpq %rsi, %rdi
ja 0x2583
movq %rbx, %rdi
callq 0x2fd0
movl 0x4(%rsp), %edx
movq (%rbx), %rax
movl (%rsp), %ecx
movl %edx, %edx
leaq (%rdx,%rdx,2), %rdx
leaq (%rax,%rdx,8), %rdi
movl %ecx, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsd2ss 0x18(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r15, %rsi
callq 0x36fa
movl 0x4(%rsp), %eax
movl (%rsp), %ecx
cmpl %ecx, %eax
je 0x25dd
leaq (%rcx,%rcx,2), %rdi
shlq $0x3, %rdi
addq (%rbx), %rdi
movl %eax, 0x8(%rsp)
xorps %xmm0, %xmm0
cvtsd2ss 0x18(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
movq %r15, %rsi
callq 0x36fa
movl 0x4(%rsp), %eax
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x3878
movl (%rsp), %eax
movl %eax, 0x8(%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x3878
movq 0x50(%rsp), %rax
leaq 0x50(%rsp), %r12
movq -0x18(%rax), %rax
testb $0x2, 0x70(%rsp,%rax)
je 0x24de
movq 0x38(%rsp), %rdi
movq 0x10(%rsp), %r12
leaq 0x28(%rsp), %rsi
movq %r12, %rdx
callq 0x3986
movq 0x18(%rbx), %r14
movq 0x20(%rbx), %r15
cmpq %r15, %r14
je 0x266d
movq %r15, %rax
subq %r14, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x3b11
movq %r14, %rdi
movq %r15, %rsi
callq 0x3bf4
leaq 0x50(%rsp), %rdi
callq 0x2060
leaq 0x20(%rsp), %rdi
callq 0x340e
leaq 0x50(%rsp), %rdi
callq 0x2070
addq $0x258, %rsp            # imm = 0x258
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, 0x10(%rsp)
movq %rax, %r14
jmp 0x26cd
movq %r12, 0x10(%rsp)
movq %rax, %r14
jmp 0x26d7
jmp 0x26c0
movq %r12, 0x10(%rsp)
jmp 0x26c0
jmp 0x26c0
jmp 0x26c0
jmp 0x26c0
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x340e
leaq 0x50(%rsp), %rdi
callq 0x2070
movq 0x10(%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x26f0
movq 0x28(%rbx), %rsi
subq %rdi, %rsi
callq 0x21a0
movq %rbx, %rdi
callq 0x300c
movq %r14, %rdi
callq 0x22b0