Python

C

Java

Python result:

C result:

Java result:

Dijkstra's Algorithm, from vertex D to F:

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, inf]

Path: D->E->C->B->F, Distance: 10

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, inf]

Path: D->E->C->B->F, Distance: 10

Dijkstra's Algorithm, from vertex D to F:

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, 2147483647]

Path: D->E->C->B->F, Distance: 10

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, 2147483647]

Path: D->E->C->B->F, Distance: 10

Dijkstra's Algorithm, from vertex D to F:

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, 2147483647]

Path: D->E->C->B->F, Distance: 10

Visited vertex: D

Visited vertex: E

Visited vertex: A

Visited vertex: C

Visited vertex: G

Visited vertex: B

Breaking out of loop. Current vertex: F

Distances: [4, 8, 6, 0, 2, 10, 7, 12, 11, 2147483647]

Path: D->E->C->B->F, Distance: 10