// File: /workspace/github_cpp_makefile_star2_O2/rtackx[P]ComSim/main.cpp
// Function: main
int main(int argc, const char* argv[])
{
	string path_dataset, similarity_index;
	int distance, depth_best;
	static set<string> list_valid_similarities = {"cn", "ji", "aa", "ra", "lhn", "pan"};

	if(argc < 3)
	{
		usage();
		return 0;
	}
	else
	{
		path_dataset = argv[1];
		distance = atoi(argv[2]);
		similarity_index = "cn";
		depth_best = 1;

		if(argc > 3)
		{
			similarity_index = argv[3];

			if(list_valid_similarities.find(similarity_index) == list_valid_similarities.end())
			{
				usage();
				cerr << endl << "\"" << similarity_index << "\" is not a valid similarity index" << endl;
				return 0;
			}

			if(argc > 4)
			{
				if(argc == 5)
					depth_best = atoi(argv[4]);
				else
				{
					usage();
					return 0;
				}
			}
		}
	}

	high_resolution_clock::time_point t1, t2;
	t1 = high_resolution_clock::now();

	Graph* main_graph = new Graph();
	cerr << "Loading graph..." << endl;
	main_graph->load_graph(path_dataset);
	cerr << "   n = " << main_graph->n << endl << "   m = " << main_graph->m/2 << endl;

	srand(unsigned(time(NULL)));

	Community* c = new Community(main_graph, depth_best);
	Projection* p;
	Graph* g;
	unsigned int nb_remaining_nodes = 0;

	g = main_graph;

	p = select_similarity(similarity_index, g);
	cerr << endl << "Projecting graph (distance : " << distance << ") ..." << endl;
	p->project(distance);

	if(p->graph_projection->n > 0)
	{
		cerr << "Detecting communities..." << endl;
		nb_remaining_nodes = c->detect(p->graph_projection);

		//g = main_graph->get_subgraph(list_ending_nodes);
	}
	cerr << "Number of remaining nodes : " << nb_remaining_nodes << endl;

	cerr << endl << "--------------" << endl;
	unsigned int i;
	for(auto& e : c->community)
	{
		for(i=0; i<e.second.size()-1; i++)
			cout << e.second[i]->id << " ";
		cout << e.second[e.second.size()-1]->id << endl;
	}
	cerr << "--------------" << endl;

	delete p;
	delete g;
	//delete main_graph;
	delete c;

	t2 = high_resolution_clock::now();
	cerr << "Time : ";
	display_ms(t1, t2);

	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rsi, %rbx
movl %edi, %r14d
xorl %ecx, %ecx
leaq 0x28(%rsp), %rdx
movq %rdx, -0x10(%rdx)
andq $0x0, -0x8(%rdx)
movb %cl, (%rax)
movb %cl, (%rdx)
movb 0xe7bb(%rip), %al       # 0x11250
testb %al, %al
je 0x2e8b
cmpl $0x3, %r14d
jge 0x2aaf
callq 0x26d7
xorl %ebx, %ebx
jmp 0x2e1a
movq 0x8(%rbx), %rsi
leaq 0x38(%rsp), %rdi
callq 0x23e0
movq 0x10(%rbx), %rdi
callq 0x2340
movl %eax, %ebp
leaq 0x7cfb(%rip), %rsi      # 0xa7ca
leaq 0x18(%rsp), %rdi
callq 0x23e0
pushq $0x1
popq %r15
cmpl $0x3, %r14d
je 0x2b26
movq 0x18(%rbx), %rsi
leaq 0x18(%rsp), %rdi
callq 0x23e0
leaq 0xe728(%rip), %rdi      # 0x11220
leaq 0x18(%rsp), %rsi
callq 0x3468
leaq 0xe71f(%rip), %rcx      # 0x11228
cmpq %rcx, %rax
je 0x2e42
cmpl $0x5, %r14d
jb 0x2b26
jne 0x2aa3
movq 0x20(%rbx), %rdi
callq 0x2340
movl %eax, %r15d
callq 0x2060
movq %rax, %rbx
pushq $0x10
popq %rdi
callq 0x2250
movq %rax, %r14
movq %rax, %rdi
callq 0x34e0
movq %r14, 0x98(%rsp)
movq 0xe4a0(%rip), %rdi      # 0x10ff0
leaq 0x7cab(%rip), %rsi      # 0xa802
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq 0x98(%rsp), %r14
leaq 0x78(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x22e0
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x3532
leaq 0x78(%rsp), %rdi
callq 0x2100
movq 0xe457(%rip), %rdi      # 0x10ff0
leaq 0x7c73(%rip), %rsi      # 0xa813
callq 0x2240
movq 0x98(%rsp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2110
leaq 0x7c55(%rip), %rsi      # 0xa81b
movq %rax, %rdi
callq 0x2240
movq 0x98(%rsp), %rcx
movl 0x4(%rcx), %esi
shrl %esi
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2110
xorl %edi, %edi
callq 0x2210
movl %eax, %edi
callq 0x2230
movl $0x80, %edi
callq 0x2250
movq %rax, %r12
leaq 0x98(%rsp), %rsi
movq %rax, %rdi
movl %r15d, %edx
callq 0x6d20
movq 0x98(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x22e0
leaq 0x58(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2919
movq %rax, %r15
leaq 0x58(%rsp), %rdi
callq 0x2100
movq 0xe398(%rip), %rdi      # 0x10ff0
callq 0x2110
leaq 0x7bbf(%rip), %rsi      # 0xa823
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
movl %ebp, %esi
callq 0x2390
leaq 0x7bc4(%rip), %rsi      # 0xa841
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r15, %rdi
movl %ebp, %esi
callq 0x5272
movq 0x18(%r15), %rax
cmpl $0x0, (%rax)
je 0x2cce
movq 0xe349(%rip), %rdi      # 0x10ff0
leaq 0x7b99(%rip), %rsi      # 0xa847
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %r15, %rsi
addq $0x18, %rsi
movq %r12, %rdi
callq 0x6d82
movl %eax, %ebp
jmp 0x2cd0
xorl %ebp, %ebp
movq 0xe319(%rip), %rdi      # 0x10ff0
leaq 0x7b82(%rip), %rsi      # 0xa860
callq 0x2240
movl %ebp, %esi
movq %rax, %rdi
callq 0x2180
movq %rax, %rdi
callq 0x2110
movq 0xe2f4(%rip), %rdi      # 0x10ff0
callq 0x2110
leaq 0x7b75(%rip), %rsi      # 0xa87d
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x2110
movq %rbx, %r14
movq %r12, 0x10(%rsp)
movq %r12, %rbp
addq $0x58, %rbp
movq 0xe29a(%rip), %r12      # 0x10fc8
leaq 0x7b0a(%rip), %r13      # 0xa83f
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x2d94
xorl %ebx, %ebx
movl %ebx, %ebx
movq 0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
leaq -0x1(%rcx), %rdx
cmpq %rbx, %rdx
jbe 0x2d79
movq (%rax,%rbx,8), %rsi
addq $0x8, %rsi
movq %r12, %rdi
callq 0x21f0
movq %rax, %rdi
movq %r13, %rsi
callq 0x2240
incl %ebx
jmp 0x2d40
movq -0x8(%rax,%rcx,8), %rsi
addq $0x8, %rsi
movq %r12, %rdi
callq 0x21f0
movq %rax, %rdi
callq 0x2110
jmp 0x2d35
movq 0xe255(%rip), %rdi      # 0x10ff0
leaq 0x7adb(%rip), %rsi      # 0xa87d
callq 0x2240
movq %r14, %rbx
movq %rax, %rdi
callq 0x2110
movq %r15, %rdi
callq 0x4ddc
movq %r15, %rdi
callq 0x2220
movq 0x8(%rsp), %r15
testq %r15, %r15
movq 0x10(%rsp), %r14
je 0x2dd9
movq %r15, %rdi
callq 0x34e8
movq %r15, %rdi
callq 0x2220
movq %r14, %rdi
callq 0x6d68
movq %r14, %rdi
callq 0x2220
callq 0x2060
movq %rax, %r14
movq 0xe1f0(%rip), %rdi      # 0x10ff0
leaq 0x7a85(%rip), %rsi      # 0xa88c
callq 0x2240
movq %rbx, %rdi
movq %r14, %rsi
callq 0x26a4
pushq $0x1
popq %rbx
leaq 0x18(%rsp), %rdi
callq 0x2100
leaq 0x38(%rsp), %rdi
callq 0x2100
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x26d7
movq 0xe1a2(%rip), %rdi      # 0x10ff0
callq 0x2110
leaq 0x7984(%rip), %rsi      # 0xa7de
movq %rax, %rdi
callq 0x2240
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x21f0
leaq 0x796a(%rip), %rsi      # 0xa7e0
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
callq 0x2110
jmp 0x2aa8
leaq 0xe3be(%rip), %rdi      # 0x11250
callq 0x23c0
testl %eax, %eax
je 0x2a9d
leaq 0x7924(%rip), %rsi      # 0xa7ca
leaq 0x98(%rsp), %r15
leaq 0x8(%rsp), %rdx
movq %r15, %rdi
callq 0x20d0
leaq 0xb8(%rsp), %r12
leaq 0x7903(%rip), %rsi      # 0xa7cd
leaq 0x7(%rsp), %rdx
movq %r12, %rdi
callq 0x20d0
leaq 0xd8(%rsp), %r12
leaq 0x78ea(%rip), %rsi      # 0xa7d0
leaq 0x6(%rsp), %rdx
movq %r12, %rdi
callq 0x20d0
leaq 0xf8(%rsp), %r12
leaq 0x78d1(%rip), %rsi      # 0xa7d3
leaq 0x5(%rsp), %rdx
movq %r12, %rdi
callq 0x20d0
leaq 0x118(%rsp), %r12
leaq 0x78b8(%rip), %rsi      # 0xa7d6
leaq 0x4(%rsp), %rdx
movq %r12, %rdi
callq 0x20d0
leaq 0x138(%rsp), %r12
leaq 0x78a0(%rip), %rsi      # 0xa7da
leaq 0x3(%rsp), %rdx
movq %r12, %rdi
callq 0x20d0
leaq 0xe2d2(%rip), %rdi      # 0x11220
leaq 0x98(%rsp), %rsi
pushq $0x6
popq %rdx
leaq 0x2(%rsp), %rcx
leaq 0x1(%rsp), %r8
callq 0x3082
movl $0xa0, %r15d
leaq (%rsp,%r15), %rdi
addq $0x98, %rdi
callq 0x2100
addq $-0x20, %r15
cmpq $-0x20, %r15
jne 0x2f6e
leaq 0x13b(%rip), %rdi       # 0x30ca
leaq 0xe28a(%rip), %rsi      # 0x11220
leaq 0xe263(%rip), %rdx      # 0x11200
callq 0x21e0
leaq 0xe2a7(%rip), %rdi      # 0x11250
callq 0x2170
jmp 0x2a9d
movq %rax, %rbx
movl $0xa0, %r14d
leaq (%rsp,%r14), %rdi
addq $0x98, %rdi
callq 0x2100
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0x2fbc
movb $0x1, %al
jmp 0x2fe7
jmp 0x2fe2
jmp 0x2fe2
jmp 0x2fe2
jmp 0x2fe2
movq %rax, %rbx
xorl %eax, %eax
cmpq %r12, %r15
sete %cl
testb %al, %al
jne 0x300b
testb %cl, %cl
jne 0x300b
addq $-0x20, %r12
movq %r12, %rdi
callq 0x2100
cmpq %r15, %r12
jne 0x2ff5
jmp 0x300b
movq %rax, %rbx
leaq 0xe23e(%rip), %rdi      # 0x11250
callq 0x2160
jmp 0x3058
jmp 0x3055
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
jmp 0x3037
movq %rax, %rbx
movq %r12, %rdi
jmp 0x3044
jmp 0x3055
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x2100
jmp 0x3058
movq %rax, %rbx
movq %r14, %rdi
callq 0x2220
jmp 0x3058
jmp 0x3055
jmp 0x3055
jmp 0x3055
jmp 0x3055
jmp 0x3055
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x2100
leaq 0x38(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x23a0