![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 76
扶柳儿
这个作者很懒,什么都没留下…
展开
-
单源最短路径 : Bellman-Ford 算法
public class BellmanFord { static boolean BellmanFord(int[][] graph, char s) { int[] p = new int[graph.length]; int[] dist = new int[graph.length]; for(int i = 0; i dist[i] = M; p[i] = -1;原创 2013-08-22 16:20:50 · 438 阅读 · 0 评论 -
最大流 : FordFulkerson 算法
import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; public class FordFulkerson { static final int M = 10000; // unreachable /** * 查找AugmentPat原创 2013-09-02 18:25:40 · 495 阅读 · 0 评论 -
每对顶点的最短路径 : Johnson 算法
import org.apache.commons.lang.builder.ToStringBuilder; /** * 稀疏图上的Johnson算法 结合 BellmanFord 和 Dijkstra 算法 * */ public class Johnson { static final int M = 10000; // unreachable /** * * @p原创 2013-08-30 16:05:13 · 544 阅读 · 0 评论 -
每对顶点的最短路径 : Floyd-Warshall 算法
public class FloydWarshall { static final int M = 10000; //unreachable //extend-shortest-path static int[][] extendShortestPath(int[][] L, int[][] W) { int[][] R = new int[L.length][L[0].lengt原创 2013-08-29 10:52:23 · 528 阅读 · 0 评论 -
每对顶点的最短路径 : 基本算法
public class AllPairsShortestPaths { static final int M = 10000; //unreachable //extend-shortest-path static int[][] extendShortestPath(int[][] L, int[][] W) { int[][] R = new int[L.length][L[原创 2013-08-29 10:39:44 · 732 阅读 · 0 评论 -
单源最短路径 : Dijkstra 算法
public class Dijkstra { static final int M = 10000; static void dijkstra(int[][] edges, int s) { int vertexs = edges.length; // dist int[] d = new int[vertexs]; // π int[] p = new int[ve原创 2013-08-27 10:12:01 · 439 阅读 · 0 评论 -
最小生成树 : Kruskal 算法
import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Kruskal { static final int M = 10000; static class Edge implements Comparable { char u; char v;原创 2013-08-22 18:12:51 · 292 阅读 · 0 评论 -
最小生成树 : Prim 算法
public class Prim { static final int M = 10000; static int extractMin(int[] key, boolean[] visited) { int min = M; int idx = -1; for(int i = 0; i < key.length; i++) { if(!visited[i] && k原创 2013-08-22 18:57:30 · 460 阅读 · 0 评论 -
Boyer-Moore算法
public class Solution { public String strStr(String haystack, String needle) { int begin = bm(haystack, needle); return begin == -1 ? null : haystack.substring(begin); } int bm(String str, Str转载 2014-04-25 12:30:14 · 490 阅读 · 0 评论