Why do we see 2 different visualizations for the questions requiring Djikstras's algorithm as a solution?
In one case I see nodes connected to each other, the other format is a 2d array. Is there a way to convert or mentally visualize the 2d array as connected nodes?
I'd like to know so I am clear on my approach to solving the question.
See references here:
Node Approach to shortest path, which presents code like this:
class Node {
private Map<Node, Integer> adjacentNodes = new HashMap<>();
// ...
}
2D Array Approach to shortest path which starts with a nodes visualisation, and then moves to this 2D array:
int graph[][] = new int[][] {
{0, 4, 0, 0, 7},
{4, 0, 1, 2, 0},
{0, 1, 0, 6, 0},
{0, 2, 6, 0, 0},
{7, 0, 0, 0, 0}
};