3. Consider the following C# code snippet implementing Dijkstra's Algorithm on a graph with 4 vertices (0 to 3). What is the shortest distance from vertex 0 to vertex 3?
int[,] graph = {
{0, 1, 4, 0},
{1, 0, 2, 6},
{4, 2, 0, 3},
{0, 6, 3, 0}
};
int V = 4;
int[] dist = new int[V];
bool[] sptSet = new bool[V];
for (int i = 0; i < V; i++) dist[i] = int.MaxValue;
dist[0] = 0;
for (int count = 0; count < V - 1; count++) {
int u = -1;
int minDist = int.MaxValue;
for (int v = 0; v < V; v++) {
if (!sptSet[v] && dist[v] < minDist) {
minDist = dist[v];
u = v;
}
}
sptSet[u] = true;
for (int v = 0; v < V; v++) {
if (!sptSet[v] && graph[u, v] != 0 && dist[u] != int.MaxValue && dist[u] + graph[u, v] < dist[v]) {
dist[v] = dist[u] + graph[u, v];
}
}
}
Console.WriteLine(dist[3]);