mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-27 14:54:05 -06:00
vault backup: 2022-10-18 12:39:16
This commit is contained in:
parent
59f8da0025
commit
ec7da009fa
@ -60,15 +60,17 @@ iterative: after k interations, know least cost path to k destinations
|
|||||||

|

|
||||||
|
|
||||||
## Dijkstra's algorithm
|
## Dijkstra's algorithm
|
||||||
|
foward search algorithm
|
||||||
|
|
||||||
initialization
|
|
||||||
```
|
```
|
||||||
|
///initialization
|
||||||
N` = {u}
|
N` = {u}
|
||||||
for all nodes v
|
for all nodes v
|
||||||
if v adjacent to u
|
if v adjacent to u
|
||||||
then D(v) = Cuv
|
then D(v) = Cuv
|
||||||
else D(v) = infinity
|
else D(v) = infinity
|
||||||
|
|
||||||
|
//loop
|
||||||
loop until all nodes in N`
|
loop until all nodes in N`
|
||||||
find W not in N` such that D(w) is a min
|
find W not in N` such that D(w) is a min
|
||||||
add w to N`
|
add w to N`
|
||||||
@ -78,6 +80,12 @@ loop until all nodes in N`
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
complexity:
|
||||||
|
- n nodes
|
||||||
|
- O(n)
|
||||||
|
|
||||||
# routing in the internet
|
# routing in the internet
|
||||||
|
|
||||||
# ICMP
|
# ICMP
|
||||||
Loading…
Reference in New Issue
Block a user