python-for-coding-test icon indicating copy to clipboard operation
python-for-coding-test copied to clipboard

Dijkstra 코드에 대한 질문있습니다.

Open hyeonuk-kor opened this issue 5 years ago • 0 comments

안녕하세요? 간단한 다익스트라 알고리즘에서 한 가지 문제점이 있는 것 같아 질문을 쓰게 됐습니다.

예를 들어

2 4 1 1 2 1 1 2 2 1 2 3 1 2 5

이러한 테스트케이스가 오게 될 경우 0과 5가 출력되게 됩니다. 올바르게 출력되기 위해서는

자바 코드 기준으로 51~54번 라인이 삭제되거나 또는 반복문을 아래와 같이

for(int i=0; i<graph.get(start).size(); i++) {
			d[graph.get(start).get(i).getIndex()] = Math.min(d[graph.get(start).get(i).getIndex()], graph.get(start).get(i).getDistance()); 
		}

수정 되어야 할 것 같습니다!

hyeonuk-kor avatar Nov 10 '20 11:11 hyeonuk-kor