摘要: 图由顶点和边组成:顶点 String[] vertices = {"Seattle","San Francisco","Los Angeles"};边:1. int[] edges = { {0, 1}, {0, 3}, {0, 5}, ...}表示顶点0到顶点1有路径。2.Edge对象:1 public static class Edge{2 public int u;3 public int v;4 public Edge(int u, int v){5 this.u = u;6 this.v ... 阅读全文
posted @ 2013-11-21 20:57 soul390 阅读(147) 评论(0) 推荐(0)
摘要: 1 /** 2 * dfs(vertex v){ 3 * visit v; 4 * for each neighbor w of v 5 * if(w has not been visited){ 6 * dfs(w); 7 * } 8 * } 9 */10 /*深度优先搜索从顶点 v 开始*/11 public Tree dfs(int v){12 List searchOrders = new Array... 阅读全文
posted @ 2013-11-21 11:04 soul390 阅读(183) 评论(0) 推荐(0)