Programming Challenge: Implementing Dijkstra's

In this lesson, you'll be implementing Dijkstra's Shortest Path Algorithm.

Problem Statement

Given an adjacency matrix in a 2D array, solve the Single Source Shortest Path algorithm, essentially by implementing the Dijkstra’s algorithm discussed in the previous lesson. We’ve written some skeleton code for the function.

  1. The value of the weight of the link is graph[src][dst].
  2. The graph is undirected so graph[src][dst]==graph[dst][src].
  3. A link between the src and dst exists if -1<graph[src][dst]<16.
  4. If graph[src][dst]>=16 the weight of the link is infinite and it does not function.

Input

  1. An adjacency matrix, i.e., a 2D array, a source node, and a destination node.

Output

The shortest path between the source and destination in the form of an array of integers where each integer represents a node and the total weight of the path.

Get hands-on with 1200+ tech skills courses.