์•Œ๊ณ ๋ฆฌ์ฆ˜) Graph - Dijkstra/Floyd-Warshall/Bellman-Ford 's Alg (distance)

Dijkstra Algorithm ๊ทธ๋ž˜ํ”„์˜ ํ•œ ๋…ธ๋“œ์—์„œ ๋‹ค๋ฅธ ๋…ธ๋“œ๋กœ ๊ฐ€๋Š” ์ตœ๋‹จ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ•˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ (๋งŒ์•ฝ ๋ชจ๋“  ๋…ธ๋“œ ์Œ๊ฐ„์˜ ์ตœ๋‹จ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ• ๋•, n๊ฐœ์˜ ๊ฐ ์ •์ ์— ๋Œ€ํ•ด Dijkstra Alg๋ฅผ ์—ฌ๋Ÿฌ๋ฒˆ ์ˆ˜ํ–‰ํ•ด์•ผํ•˜๋ฏ€๋กœ, ์ด๋•Œ๋Š” Floyd-Warshall Alg์ด ๋” ์œ ๋ฆฌํ•˜๋‹ค) ๋™์ž‘๊ณผ์ •์€ BFS์™€ ๋น„์Šทํ•˜์ง€๋งŒ, Queue๊ฐ€ ์•„๋‹Œ Priority Queue๋ฅผ ์ด์šฉํ•œ๋‹ค. ์‹œ๊ฐ„๋ณต์žก๋„=O(ElogE) ํ•ด๋‹น๋…ธ๋“œ๊นŒ์ง€์˜ ์ตœ๋‹จ๊ฑฐ๋ฆฌ๋ฅผ ์ €์žฅํ•  distance[] ๋ฐฐ์—ด ์ค€๋น„ํ›„, ๋ฏธ๋ฐฉ๋ฌธ์„ ์˜๋ฏธํ•˜๋Š” -1๋กœ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค. ๋…ธ๋“œ1์—์„œ ์‹œ์ž‘ํ•œ๋‹ค๋ฉด, ์ด๋•Œ๊นŒ์ง€ ์ž๊ธฐ์ž์‹  1๊นŒ์ง€์˜ ๊ฑฐ๋ฆฌ๋Š” 0์ด๋ฏ€๋กœ distance[1]์— 0์„, pq์— (1,0)์„ ๋„ฃ๋Š”๋‹ค. 2์˜10๋ณด๋‹ค ๊ฐ€๊น๋‹ค. distance[2]=8๋กœ ๊ฐฑ์‹ , pq์—๋„ (2,8) ๋„ฃ๋Š”๋‹ค. pq์—” (..

Algorithm 2019. 9. 13. 14:00
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/11   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
๊ธ€ ๋ณด๊ด€ํ•จ