๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์•Œ๊ณ ๋ฆฌ์ฆ˜17

16-3๊ฐ•. ์ตœ๋‹จ๊ฒฝ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ (Shortest Path Algorithm) (3) ์ด์ „ ๊ฐ•์ขŒ ์ฒจ๋ถ€,, 16-3๊ฐ•. ์ตœ๋‹จ๊ฒฝ๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ (Shortest Path Algorithm) (3) ์ด์ „ ๊ฐ•์ขŒ,,, Bellman-Ford Algo- ๋‚˜ Dijkstra Algo-๋Š” one-to-all ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด์—ˆ๋‹ค. ์ด๋ฒˆ ๊ฐ•์ขŒ์—์„œ๋Š” all-to-all ์•Œ๊ณ ๋ฆฌ์ฆ˜์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•œ๋‹ค. all-to-all ์•Œ๊ณ ๋ฆฌ์ฆ˜์˜ ํ•˜๋‚˜๊ฐ€ Floyd Algorithm ํ˜น์€ Floyd-Warshall Algorithm์ด๋‹ค. Floyd-Warshall ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ๊ฐ€์ค‘์น˜ ๋ฐฉํ–ฅ ๊ทธ๋ž˜ํ”„ G=(V, E), V={1, 2, ..., n} (๋…ธ๋“œ๋“ค์—๋Š” 1๋ฒˆ๋ถ€ํ„ฐ n๋ฒˆ๊นŒ์ง€ ๋ฒˆํ˜ธ๊ฐ€ ๋ถ™์–ด ์žˆ๋‹ค..) - ๋ชจ๋“  ๋…ธ๋“œ ์Œ๋“ค ๊ฐ„์˜ ์ตœ๋‹จ๊ฒฝ๋กœ์˜ ๊ธธ์ด๋ฅผ ๊ตฌํ•จ - d์˜ k์Šน[i, j] ใ„ด ์ค‘๊ฐ„์— ๋…ธ๋“œ์ง‘ํ•ฉ {1, 2, ..., k}์— ์†ํ•œ ๋…ธ๋“œ๋“ค๋งŒ ๊ฑฐ์ณ์„œ ๋…ธ.. 2021. 1. 10.
16-1๊ฐ•. ์ตœ๋‹จ๊ฒฝ๋กœ (Shortest Path Problem) (1) ์•„์ดํŒจ๋“œ ๊ตฟ๋…ธํŠธ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ ์€ ํ•„๊ธฐ 2021. 1. 6.
15-4. ์ตœ์†Œ๋น„์šฉ์‹ ์žฅํŠธ๋ฆฌ( Minimum Spanning Tree) Prim์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ์ž„์˜์˜ ๋…ธ๋“œ๋ฅผ ์ถœ๋ฐœ๋…ธ๋“œ๋กœ ์„ ํƒ - ์ถœ๋ฐœ ๋…ธ๋“œ๋ฅผ ํฌํ•จํ•˜๋Š” ํŠธ๋ฆฌ๋ฅผ ์ ์  ํ‚ค์›Œ ๊ฐ (ํฌ๋Ÿฌ์Šค์นผ์€ ์—์ง€๋“ค์˜ ๊ฐ€์ค‘์น˜๊ฐ€ ์ž‘์€ ์ˆœ์„œ๋Œ€๋กœ ์ ‘๊ทผํ•˜๋Š” ๋ฐฉ๋ฒ•์ด์—ˆ๋‹ค๋ฉด, ํ”„๋ฆผ์€ ์ถœ๋ฐœ๋…ธ๋“œ๋ถ€ํ„ฐ ์—ฐ๊ฒฐ ์—ฐ๊ฒฐ๋œ ๋…ธ๋“œ๋“ค์„ ํƒ์ƒ‰ํ•˜์—ฌ ํŠธ๋ฆฌ๋ฅผ ํ‚ค์šด๋‹ค) - ๋งค ๋‹จ๊ณ„์—์„œ ์ด๋ฏธ ํŠธ๋ฆฌ์— ํฌํ•จ๋œ ๋…ธ๋“œ์™€ ํฌํ•จ๋˜์ง€ ์•Š์€ ๋…ธ๋“œ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ์—์ง€๋“ค ์ค‘ ๊ฐ€์žฅ ๊ฐ€์ค‘์น˜๊ฐ€ ์ž‘์€ ์—์ง€๋ฅผ ์„ ํƒ ์œ„์˜ ๊ทธ๋ž˜ํ”„์—์„œ ์ถœ๋ฐœ ๋…ธ๋“œ๊ฐ€ ์ดˆ๋ก์ƒ‰ ๋…ธ๋“œ๋ผ๊ณ  ํ•˜๋ฉด, ์ถœ๋ฐœ ๋…ธ๋“œ์— ์ธ์ ‘ํ•œ ๋…ธ๋“œ๋“ค์„ A๋ผ ํ•˜๋ฉด, ๊ทธ ๋ถ€๋ถ„ํŠธ๋ฆฌ์— ํฌํ•จ๋œ ๋…ธ๋“œ๋“ค์˜ ์ง‘ํ•ฉ์€ V of A(๋นจ๊ฐ„ ๋…ธ๋“œ๋“ค)๋ผ ํ•˜์ž. (a) : ์ถœ๋ฐœ๋…ธ๋“œ a ์—์„œ ์ธ์ ‘ํ•œ ๋…ธ๋“œ b์™€ ๋…ธ๋“œ k ๊ฐ€ ์žˆ๋‹ค. ๊ฐ€์ค‘์น˜๊ฐ€ ์ž‘์€ ์—์ง€๋Š” 4์ด๋ฏ€๋กœ ๋…ธ๋“œ b๋ฅผ ์„ ํƒํ•œ๋‹ค. (b) : ์ด์ œ ๋…ธ๋“œ a ์™€ ๋…ธ๋“œ b๋Š” V of A์˜ ๋ถ€๋ถ„์ง‘ํ•ฉ์ด ๋˜์—ˆ๋‹ค. (c.. 2020. 12. 17.
15-2๊ฐ•. ์ตœ์†Œ๋น„์šฉ์‹ ์žฅํŠธ๋ฆฌ (Minimum Spanning Tree) (2) ์ตœ์†Œ๋น„์šฉ์‹ ์žฅํŠธ๋ฆฌ (Minimum Spanning Tree) Kruskal์˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜ - ์—์ง€๋“ค์„ ๊ฐ€์ค‘์น˜์˜ ์˜ค๋ฆ„์ฐจ์ˆœ์œผ๋กœ ์ •๋ ฌํ•œ๋‹ค. - ์—์ง€๋“ค์„ ๊ทธ ์ˆœ์„œ๋Œ€๋กœ ํ•˜๋‚˜์”ฉ ์„ ํƒํ•ด ๊ฐ„๋‹ค. ๋‹จ, ์ด๋ฏธ ์„ ํƒ๋œ ์—์ง€๋“ค๊ณผ ์‚ฌ์ดํด(cycle)์„ ํ˜•์„ฑํ•˜๋ฉด ์„ ํƒํ•˜์ง€ ์•Š๋Š”๋‹ค. - n-1๊ฐœ์˜ ์—์ง€๊ฐ€ ์„ ํƒ๋˜๋ฉด ์ข…๋ฃŒํ•œ๋‹ค. ์œ„์˜ ๊ทธ๋ž˜ํ”„์—์„œ, ๋ชจ๋ฅธ ์—์ง€๋“ค์„ ์ž‘์€ ๊ฒƒ๋ถ€ํ„ฐ ํฐ ๊ฒƒ ์ˆœ์œผ๋กœ ์ •๋ ฌํ•ด ๋‘์—ˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. (a) : ๊ฐ€์žฅ ๊ฐ€์ค‘์น˜(weight)๊ฐ€ ์ž‘์€ ์—์ง€(1)๋ฅผ ์„ ํƒํ•œ๋‹ค. => ๋‚ด๊ฐ€ ์„ ํƒํ•œ ์—์ง€๋“ค์€ cycle์„ ํ˜•์„ฑํ•˜์ง€ ์•Š๋Š”๋‹ค. (์™œ? ์—์ง€๊ฐ€ ํ•˜๋‚˜๋ฐ–์— ์„ ํƒ๋˜์ง€ ์•Š์•˜์œผ๋‹ˆ๊นŒ) (b) : ๊ทธ ๋‹ค์Œ์œผ๋กœ ๊ฐ€์ค‘์น˜(weight)๊ฐ€ ์ž‘์€ ์—์ง€(2)๋ฅผ ์„ ํƒํ•œ๋‹ค. => cycle์„ ํ˜•์„ฑํ•˜์ง€ ์•Š๋Š”๋‹ค. (c) : ๊ทธ ๋‹ค์Œ์œผ๋กœ ๊ฐ€์ค‘์น˜(weight)๊ฐ€ ์ž‘์€ ์—.. 2020. 12. 13.