let bfs = (node) => {

}

let Node = (value) => {
	this.value = value;
	this.children = [];
}

Node.prototype.addChild = (child) => {
	this.children.push(child);
	return child;
}
let root = new Node(1);
let rootChild1 = root.addChild(new Node(2));
let rootChild2 = root.addChild(new Node(3));
let leaf1 = rootChild1.addChild(new Node(4));
let leaf2 = rootChild1.addChild(new Node(5));

let bfs = (node) => {
	// 최종적으로 리턴할 배열 변수를 만들어준다.
	let result = [];
	// 큐를 만들어준다. -> 큐에 초기 node값을 넣어둔다. -> queue = [1]
	let queue = [node]

	// 큐의 길이가 0보다 클때까지 while문을 돌려준다.
	while(queue.length > 0) {
		// queue의 0번째 인덱스 요소를 담아둘 변수를 만들어준다. -> head = 1
		let head = queue[0];
		// 큐는 head를 제외한 나머지로 세팅해준다. -> queue = []
		queue = queue.slice(1);

		// result에 head.value(node.value)를 넣어준다.
		result.push(head.value);

		// head(node)의 children을 탐색해서 큐에 넣어준다. -> queue = [2, 3]
		head.children.forEach((el) => queue.push(el))
	}
	return result;
}

let Node = (value) => {
	this.value = value;
	this.children = [];
}

Node.prototype.addChild = (child) => {
	this.children.push(child);
	return child;
}