| Home Page |
| Course Page |
For all vertices V:
visited[V] = false
DepthFirstSearch (starting vertex)
DepthFirstSearch (Vertex V)
If not visited[V]:
Application specific processing for V goes here
visited[V] = true
For each vertex W adjacent to V:
DepthFirstSearch (W)
For all vertices V:
distance[V] = infinity
distance[starting vertex] = 0
Put all vertices into a minimum priority queue by distance
While queue is not empty:
V = Extract minimum vertex from queue
For each vertex W adjacent to V:
If distance[W] > distance[V] + weight[V,W]:
predecessor[W] = V
distance[W] = distance[V] + weight[V,W]
Decrease key of W in queue
For i = 1 to N:
For r = 1 to N:
For c = 1 to N:
D[r,c] = min (D[r,c], D[r,i] + D[i,c])
For all vertices V:
minweight[V] = infinity
minweight[starting vertex] = 0
Put all vertices into a minimum priority queue by minweight
While queue is not empty:
V = Extract minimum vertex from queue
For each vertex W adjacent to V:
If W is still in the queue and weight[V,W] < minweight[W]:
predecessor[W] = V
minweight[W] = weight[V,W]
Decrease key of W in queue
(minweight[V] is the smallest weight between vertex V and any vertex in the minimum spanning tree)
| Graph: | Maximum flow from A to F = 12: | |
![]() |
![]() |
| Graph: | Maximum flow from D to F = 8: | |
![]() |
![]() |
| Course Page |
| Home Page |