프로그래밍/알고리즘
2021. 1. 22.
BFS - 너비 우선 탐색 (C#으로 길 찾기 구현)
- Breadth-First Search의 약자 - 루트 노드에서 인접한 노드를 탐색하며 순회하는 탐색 방법 - BFS와 대조되는 DFS (깊이 우선 탐색)도 있다. - Queue를 이용하여 구현하는게 일반적이다. - Queue가 모두 소진될 때까지 루프하며 인접 노드들을 검색한다. using System; using System.Collections.Generic; class Program { static void Main(string[] args) { MapController mapController = new MapController(); // 시작 좌표와 목적지 좌표를 매개변수로 넘겨준다. mapController.BFS(0, 0, 5, 3); } } public class MapControlle..