We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7664c01 commit 80daf7bCopy full SHA for 80daf7b
src/main/kotlin/de/ronny_h/aoc/extensions/graphs/TravelingSalesman.kt
@@ -28,15 +28,7 @@ class TravelingSalesman(private val adj: List<List<Int>>) {
28
/**
29
* Find the minimum edge cost having an end at the vertex [node]
30
*/
31
- private fun firstMin(node: Int): Int {
32
- var min = MAX_WEIGHT
33
- for (otherNode in 0..<N) {
34
- if (adj[node][otherNode] < min && node != otherNode) {
35
- min = adj[node][otherNode]
36
- }
37
38
- return min
39
+ private fun firstMin(node: Int) = adj[node].filterIndexed { i, _ -> i != node }.min()
40
41
42
* Find the second minimum edge cost having an end at the vertex [node]
0 commit comments