|
2 | 2 |
|
3 | 3 | ## 문제
|
4 | 4 |
|
5 | | -방향 가중치 그래프 <imgsrc="https://render.githubusercontent.com/render/math?math=G(V,E)">와 시작점 <imgsrc="https://render.githubusercontent.com/render/math?math=s \in V">가 주어졌을 때, 각 점 <imgsrc="https://render.githubusercontent.com/render/math?math=v \in V">에 대하여 <imgsrc="https://render.githubusercontent.com/render/math?math=s">와 <imgsrc="https://render.githubusercontent.com/render/math?math=v">를 잇는 가장 짧은 경로를 구하라. (<imgsrc="https://render.githubusercontent.com/render/math?math=V">는 꼭짓점의 집합, <imgsrc="https://render.githubusercontent.com/render/math?math=E">는 간선의 집합) |
| 5 | +방향 가중치 그래프 $G(V, E)$와 시작점 $s \in V$가 주어졌을 때, 각 점 $v \in V$에 대하여 $s$와 $v$를 잇는 가장 짧은 경로를 구하라. ($V$는 꼭짓점의 집합, $E$는 간선의 집합) |
6 | 6 |
|
7 | 7 | ## 절차
|
8 | 8 |
|
9 | 9 | 1. 시작점에서 모든 꼭짓점까지의 거리를 무한대로 초기화한다.
|
10 | 10 | 2. 시작점으로의 거리를 0으로 초기화한다.
|
11 | | -3. `dist[s]`를 제외한 모든 값을 무한대로 하는 크기가 <imgsrc="https://render.githubusercontent.com/render/math?math=|V|">인 `dist`라는 배열을 만든다. |
12 | | -4. 다음을 <imgsrc="https://render.githubusercontent.com/render/math?math=|V|-1">회 반복한다. |
13 | | -5. <imgsrc="https://render.githubusercontent.com/render/math?math=E">에 속한 모든 간선 `(u,v)`에 대해 다음을 반복한다: |
| 11 | +3. `dist[s]`를 제외한 모든 값을 무한대로 하는 크기가 $|V|$인 `dist`라는 배열을 만든다. |
| 12 | +4. 다음을 $|V|-1$회 반복한다. |
| 13 | +5. $E$에 속한 모든 간선 `(u,v)`에 대해 다음을 반복한다: |
14 | 14 |
|
15 | 15 | ```
|
16 | 16 | dist[v] = minimum(dist[v], dist[u] + weight of edge)
|
|
20 | 20 |
|
21 | 21 | ## 시간 복잡도
|
22 | 22 |
|
23 | | -<imgsrc="https://render.githubusercontent.com/render/math?math=O(VE)"> |
| 23 | +$O(VE)$ |
24 | 24 |
|
25 | 25 | ## 공간 복잡도
|
26 | 26 |
|
27 | | -<imgsrc="https://render.githubusercontent.com/render/math?math=O(V^2)"> |
| 27 | +$O(V^2)$ |
28 | 28 |
|
29 | 29 | ## 만든 사람
|
30 | 30 |
|
|
0 commit comments