File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed
src/main/java/cn/codepub/algorithms/graph Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change 22
22
* @since V1.0.0
23
23
*/
24
24
public class Kruskal {
25
+ private static List <Vertex > vertexList = new ArrayList <>();//顶点集
25
26
/**
26
27
* 实现一个匿名类,提供了基于边的权值的比较器
27
28
*/
28
- public static final Queue <Edge > QUEUE = new PriorityQueue <Edge >(new Comparator () {
29
+ public static final Queue <Edge > QUEUE = new PriorityQueue <Edge >(new Comparator < Edge > () {
29
30
@ Override
30
- public int compare (Object o1 , Object o2 ) {
31
- Edge e1 = (Edge ) o1 ;
32
- Edge e2 = (Edge ) o2 ;
31
+ public int compare (Edge e1 , Edge e2 ) {
33
32
if (e1 .value == e2 .value ) {
34
33
return 0 ;
35
34
} else {
36
35
return e1 .value > e2 .value ? 1 : -1 ;
37
36
}
38
37
}
39
38
});
40
- private static List <Vertex > vertexList = new ArrayList <>();//顶点集
41
39
private static List <Edge > visitedEdges = new ArrayList <>();//已访问的边集
42
40
private static List <Edge > edgeList = new ArrayList <>();//边集
43
41
44
-
45
42
private static class Vertex {
46
43
char name ;//顶点名称
47
44
You can’t perform that action at this time.
0 commit comments