Skip to content

Commit 4b708fe

Browse files
committed
refactor: 이미 크루스칼 알고리즘에 종속적인 PriorityQueue를 사용해 전략패턴 제거
1 parent c3eb810 commit 4b708fe

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

yoonexample/src/main/java/graph/ListWeightGraph.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public String showGraphEdgeWeightInfo() {
5656
}
5757

5858
@Override
59-
public void convertToMST(MSTConversionAlgorithm algorithm) {
59+
public void convertToMST() {
6060

6161
}
6262

yoonexample/src/main/java/graph/MSTConversionAlgorithm.java

-5
This file was deleted.

yoonexample/src/main/java/graph/WeightedGraph.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ public interface WeightedGraph extends Graph {
2424
String showGraphEdgeWeightInfo();
2525

2626
/**
27-
* 알고리즘을 선택해서 최소신장 트리로 변환합니다. (전략 패턴)
28-
*
29-
* @param algorithm 사용할 알고리즘
27+
* 크루스칼 알고리즘을 이용해 최소신장 트리로 변환합니다.
3028
*/
31-
void convertToMST(MSTConversionAlgorithm algorithm);
29+
void convertToMST();
3230
}

yoonexample/src/test/java/graph/WeightedGraphTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void setUp() {
9494
graph.addEdge(Point.E, Point.C, 7);
9595
graph.addEdge(Point.F, Point.E, 13);
9696

97-
graph.convertToMST(new KruskalAlgorithm());
97+
graph.convertToMST();
9898
assertThat(graph.showGraphEdgeInfo()).isEqualTo("A: D\nB: C\nC: B D\nD: A C E F\nE: D\nF: D\n");
9999
assertThat(graph.showGraphEdgeWeightInfo())
100100
.isEqualTo("(A-D), w: 8\n(D-C), w: 6\n(F-D), w:4\n(D-E), w:3\n(B-C), w:2\n");

0 commit comments

Comments
 (0)