다익스트라 알고리즘
-
다익스트라(Dijkstra) 구현_Java코딩테스트/SWEA_Java 2023. 2. 25. 14:55
import java.util.PriorityQueue; class Solution { static int INF = 987654321; static int MAX_N = 6; static class Pair implements Comparable{ int x, y; Pair(int x, int y){ this.x = x; this.y = y; } @Override public int compareTo(Pair o) { if (o.x == this.x) return this.y - o.y; else return this.x - o.x; } } static int graph[][] = new int[][]{ {0,2,5,1,INF,INF}, {2,0,3,2,INF,INF}, {5,3,0,3,1,5}, {1..