java单源最短路径(贪心算法)
public class TheShortestWay {
static int MAX_SIZE = 6;
public static void dijkstra(int v, float[][] a, float[] dist, int[] prev) {
int n = dist.length - 1;
if (v < 1 || v > n)
return;
boolean[] s = new boolean[n + 1];
for (int i = 1; i <= n; i++) {
dist[i] = a[v][i];
s[i] = false;
if (dist[i] == Float.MAX_VALUE)
prev[i] = 0;
else
prev[i] = v;
1