文件名称:java单源最短路径(贪心算法)
文件大小:2KB
文件格式:JAVA
更新时间:2017-01-06 03:29:01
java 贪心算法 单源最短路径
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;