BFS 2

๊ทธ๋ž˜ํ”„

๊ทธ๋ž˜ํ”„์˜ ์ถ”์ƒ ์ž๋ฃŒํ˜• void GraphInit(UALGraph *pg, int nv) ๊ทธ๋ž˜ํ”„์˜ ์ดˆ๊ธฐํ™”๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค. ๋‘ ๋ฒˆ์งธ ์ธ์ž๋กœ ์ •์ ์˜ ์ˆ˜๋ฅผ ์ „๋‹ฌํ•œ๋‹ค. void GraphDestroy(UALGraph *pg) ๊ทธ๋ž˜ํ”„ ์ดˆ๊ธฐํ™” ๊ณผ์ •์—์„œ ํ• ๋‹นํ•œ ๋ฆฌ์†Œ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค. void AddEdge(UALGraph *pg, int fromV, int Tov) ๋งค๊ฐœ๋ณ€์ˆ˜ fromV์™€ toV๋กœ ์ „๋‹ฌ๋œ ์ •์ ์„ ์—ฐ๊ฒฐํ•˜๋Š” ๊ฐ„์„ ์„ ๊ทธ๋ž˜ํ”„์— ์ถ”๊ฐ€ํ•œ๋‹ค. void ShowGraphEdgeInfo(UALGraph *pg) ๊ทธ๋ž˜ํ”„์˜ ๊ฐ„์„ ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๊ทธ๋ž˜ํ”„๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋‘๊ฐ€์ง€ ๋ฐฉ๋ฒ• ์ธ์ ‘ ํ–‰๋ ฌ ๊ธฐ๋ฐ˜ ๊ทธ๋ž˜ํ”„ ์ธ์ ‘ ๋ฆฌ์ŠคํŠธ ๊ธฐ๋ฐ˜ ๊ทธ๋ž˜ํ”„ ์ธ์ ‘ ํ–‰๋ ฌ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ตฌํ˜„ ํ•  ๊ฒฝ์šฐ ์—ฐ๊ฒฐ ๋˜์–ด ์žˆ๋Š” ์„ ์ด ์žˆ๋Š” ๋ฐฉํ–ฅ์— 1์„ ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ 0์„ ํ‘œ์‹œํ•œ๋‹ค. ..

BFS ๊ตฌํ˜„

BFS ๊ฐœ๋…: https://yongdeok.tistory.com/entry/%EA%B7%B8%EB%9E%98%ED%94%84 DFS๋ฅผ ์™„์ „ํžˆ ์ดํ•ดํ•˜๋ฉด ๋” ์‰ฝ๊ฒŒ ์ดํ•ดํ•  ์ˆ˜ ์žˆ๋‹ค. compile with CircularQueue → https://yongdeok.tistory.com/7 LinkedList → https://yongdeok.tistory.com/3 Bfs.c void BFShowGraphVertex(ALGraph *pg, int startV) { Queue queue; int visitV = startV; int nextV; QueueInit(&queue); VisitVertex(pg, visitV); while (LFirst(&(pg->adjList[visitV]), &nextV) == ..