알고리즘/이론1 Kruskal Kruskal MST를 만드는 알고리즘 중 하나이다 간선이 많을 때 사용하면 Prim 알고리즘보다 성능이 좋다 수도 코드 1.Edge 클래스 생성 & edgeList 생성 2.union-find 메서드들 생성 findSet, isSameParent, union 3.makeSet 4.간선의 가중치 기준 오름차순 정렬 5.모든 간선을 탐색하며 다른 집합에 속하면 sum갱신 & union 자바로 구현한 Kruskal public class Kruskal { static class Edge implements Comparable{ int a, b, cost; public Edge(int a, int b, int cost) { super(); this.a = a; this.b = b; this.cost = cos.. 2020. 5. 19. 이전 1 다음