// File: /workspace/github_cpp_makefile_star2_O2/Kingsford-Group[P]ghost2/src/laplacian.hpp
// Function: AdjacencyMatrix::extend(Graph*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void AdjacencyMatrix::extend(Graph *input, string source)
{
  if(nodes.empty())
  {
    nodes.insert(source);
    prev.push_back(source);
    neighborhoods[source] = (*input).neighbors2(source);
    dmap[source] = 0;
  }

  vector<string> next;
  for(int i=0;i<prev.size();i++)
  {
    vlist::iterator vit = (*(neighborhoods[prev[i]])).begin(), 
                    vend = (*(neighborhoods[prev[i]])).end();
    for(; vit != vend; vit++)
      if(nodes.find(*vit) == nodes.end())
      {
        nodes.insert(*vit);
        next.push_back(*vit);
        neighborhoods[*vit] = (*input).neighbors2(*vit);
        dmap[*vit] = 0;
        vlist *neighbors = (*input).neighbors2(*vit);
        vlist::iterator it = (*neighbors).begin(), iend = (*neighbors).end();
        for(; it != iend; it++)
          if(nodes.find(*it) != nodes.end())
          {
            dmap[*vit] += 1;
            dmap[*it] += 1;
            nedge++;
          }
      }
  }
  prev = next;

  nvert = nodes.size();
  m.resize(nvert,nvert);

  if(prev.size() != 0)
  {
    vlist::iterator it1 = nodes.begin(), iend = nodes.end();
    int c1=0, c2=0;
    for(; it1 != iend; it1++)
    {
      vlist::iterator it2 = nodes.begin();
      for(; it2 != iend; it2++)
      {
        if(c1 == c2)
          m(c1,c2) = 1;
        else
        {
          if((*(neighborhoods[*it1])).find(*it2) != 
             (*(neighborhoods[*it1])).end())
            m(c1,c2) = -1. / sqrt(dmap[*it1] * dmap[*it2]);
          else
            m(c1,c2) = 0;
        }
        c2++;
      } 
      c1++; 
      c2=0;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, (%rsp)
movq %rdi, %r12
leaq 0x18(%rdi), %r14
cmpq $0x0, 0x28(%rdi)
jne 0x10ec4
movq %rdx, %r15
movq %r14, %rdi
movq %rdx, %rsi
callq 0x21e20
leaq 0xa8(%r12), %rdi
movq %r15, %rsi
callq 0x186ec
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xe7a0
movq (%rsp), %rdi
movq %rbx, %rsi
callq 0x1b558
movq %rax, %rbx
leaq 0x78(%r12), %rdi
movq %r15, %rsi
callq 0x2839e
addq $0x30, %rbx
movq %rbx, 0x30(%rax)
leaq 0x68(%rsp), %rdi
callq 0xe290
leaq 0x48(%r12), %rdi
movq %r15, %rsi
callq 0x28a56
andl $0x0, 0x30(%rax)
leaq 0x30(%rsp), %rax
andq $0x0, 0x10(%rax)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rax)
leaq 0xa8(%r12), %rax
movq %rax, 0x10(%rsp)
leaq 0x78(%r12), %r15
movq %r12, 0x8(%rsp)
addq $0x48, %r12
xorl %ebx, %ebx
movq %r15, 0x20(%rsp)
movq 0x8(%rsp), %rax
movq 0xa8(%rax), %rsi
movq 0xb0(%rax), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rbx, %rax
jbe 0x1106d
movq %rbx, 0x18(%rsp)
shlq $0x5, %rbx
addq %rbx, %rsi
movq %r15, %rdi
callq 0x2839e
movq 0x30(%rax), %rdi
callq 0x1873a
movq %rax, %rbp
movq 0x10(%rsp), %rax
addq (%rax), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2839e
testq %rbp, %rbp
je 0x11060
leaq 0x10(%rbp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x2910c
testq %rax, %rax
je 0x10f76
movq (%rbp), %rbp
movq 0x20(%rsp), %r15
jmp 0x10f4e
movq %r14, %rdi
movq %r15, %rsi
callq 0x21e20
movq 0x20(%rsp), %r13
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x186ec
leaq 0x48(%rsp), %rdi
movq %r15, %rsi
callq 0xe7a0
movq (%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b558
movq %rax, %rbx
movq %r13, %rdi
movq %r15, %rsi
callq 0x2839e
addq $0x30, %rbx
movq %rbx, 0x30(%rax)
leaq 0x48(%rsp), %rdi
callq 0xe290
movq %r12, %rdi
movq %r15, %rsi
callq 0x28a56
andl $0x0, 0x30(%rax)
leaq 0x88(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0xe7a0
movq (%rsp), %rdi
movq %r13, %rsi
callq 0x1b558
movq %rax, %rbx
addq $0x30, %rbx
movq %r13, %rdi
callq 0xe290
movq %rbx, %rdi
callq 0x1873a
movq %rax, %r13
testq %r13, %r13
je 0x10f6b
leaq 0x10(%r13), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2910c
testq %rax, %rax
je 0x1105a
movq %r12, %rdi
movq %r15, %rsi
callq 0x28a56
incl 0x30(%rax)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x28a56
incl 0x30(%rax)
movq 0x8(%rsp), %rax
incl 0xc4(%rax)
movq (%r13), %r13
jmp 0x11016
movq 0x18(%rsp), %rbx
incq %rbx
jmp 0x10ef8
leaq 0x30(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0x18cec
movq 0x8(%rsp), %rbx
movq 0x28(%rbx), %rax
movl %eax, 0xc0(%rbx)
movslq %eax, %rdx
movq %rbx, %rdi
movq %rdx, %rsi
callq 0x18db6
movq 0xb0(%rbx), %rax
cmpq 0xa8(%rbx), %rax
je 0x111e1
movq %r14, %rdi
callq 0x1873a
movq %rax, %rbx
xorl %eax, %eax
testq %rbx, %rbx
je 0x111e1
movq %rax, (%rsp)
movq %r14, %rdi
callq 0x1873a
movq %rax, %r15
movq %rbx, 0x28(%rsp)
leaq 0x10(%rbx), %rax
movq %rax, 0x18(%rsp)
xorl %r13d, %r13d
testq %r15, %r15
je 0x111cd
movq (%rsp), %rdx
cmpq %r13, %rdx
jne 0x11114
movq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x18b38
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
jmp 0x111c2
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x2839e
movq 0x30(%rax), %rdi
leaq 0x10(%r15), %rbp
movq %rbp, %rsi
callq 0x2910c
movq %rax, %rbx
movq 0x20(%rsp), %rdi
movq 0x18(%rsp), %rsi
callq 0x2839e
testq %rbx, %rbx
je 0x1117d
movq %r12, %rdi
movq 0x18(%rsp), %rsi
callq 0x28a56
movl 0x30(%rax), %ebx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x28a56
imull 0x30(%rax), %ebx
cvtsi2sd %ebx, %xmm0
ucomisd 0x2ef0b(%rip), %xmm0    # 0x40080
jb 0x11194
sqrtsd %xmm0, %xmm0
jmp 0x11199
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x18b38
andq $0x0, (%rax)
jmp 0x111c2
callq 0xe430
movsd %xmm0, 0x10(%rsp)
movq 0x8(%rsp), %rdi
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x18b38
movsd 0x2eec0(%rip), %xmm0    # 0x40078
divsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
incq %r13
movq (%r15), %r15
jmp 0x110e3
movq (%rsp), %rax
incq %rax
movq 0x28(%rsp), %rbx
movq (%rbx), %rbx
jmp 0x110ba
leaq 0x30(%rsp), %rdi
callq 0x18718
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xe290
jmp 0x11249
jmp 0x1123c
jmp 0x1123c
jmp 0x1123c
jmp 0x1123c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x1122d
jmp 0x1123c
jmp 0x1123c
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xe290
jmp 0x1123f
jmp 0x1123c
jmp 0x1123c
jmp 0x1123c
jmp 0x1123c
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x18718
movq %rbx, %rdi
callq 0xe9f0
nop