File tree 3 files changed +14
-17
lines changed
3 files changed +14
-17
lines changed Original file line number Diff line number Diff line change 1
1
plugins {
2
2
id ' java'
3
- id ' org.jetbrains.kotlin.jvm' version ' 1.3.50 '
3
+ id " org.jetbrains.kotlin.jvm" version " 1.6.21 "
4
4
}
5
5
6
6
group ' com.jemshit'
7
7
version ' 1.0'
8
8
9
- sourceCompatibility = 1.8
10
-
11
9
repositories {
12
10
mavenCentral()
13
11
}
14
12
15
- dependencies {
16
- implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8"
17
-
18
- testImplementation ' org.junit.jupiter:junit-jupiter-api:5.4.2'
19
- testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.4.2'
20
- }
21
-
22
13
compileKotlin {
23
14
kotlinOptions. jvmTarget = " 1.8"
24
15
}
25
16
compileTestKotlin {
26
17
kotlinOptions. jvmTarget = " 1.8"
27
18
}
28
-
29
19
test {
30
20
useJUnitPlatform()
31
- }
21
+ }
22
+
23
+ dependencies {
24
+ implementation " org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21"
25
+
26
+ testImplementation ' org.junit.jupiter:junit-jupiter-api:5.4.2'
27
+ testRuntimeOnly ' org.junit.jupiter:junit-jupiter-engine:5.4.2'
28
+ }
Original file line number Diff line number Diff line change 1
1
distributionBase =GRADLE_USER_HOME
2
2
distributionPath =wrapper/dists
3
- distributionUrl =https\://services.gradle.org/distributions/gradle-5.2.1 -bin.zip
3
+ distributionUrl =https\://services.gradle.org/distributions/gradle-7.2 -bin.zip
4
4
zipStoreBase =GRADLE_USER_HOME
5
5
zipStorePath =wrapper/dists
Original file line number Diff line number Diff line change 1
1
package graph
2
2
3
3
fun GraphUsingAdjacencyList.shortestPathDAG (): Array <Int > {
4
- val shortestPaths = arrayOfNulls <Int >(nodeCount)
4
+ val shortestPaths = Array <Int >(nodeCount) { 0 }
5
5
val topologicalOrdering = this .topologicalOrdering()
6
6
shortestPaths[0 ] = 0
7
7
for (node in topologicalOrdering) {
8
8
val edges = getEdges(node)
9
9
for (edge in edges) {
10
10
val neighbour = edge.end
11
- val distanceToNeighbour = ( shortestPaths[node] ? : 0 ) + (edge.weight ? : 0 )
12
- if (shortestPaths[neighbour] == null || distanceToNeighbour < shortestPaths[neighbour]!! ) {
11
+ val distanceToNeighbour = shortestPaths[node] + (edge.weight ? : 0 )
12
+ if (distanceToNeighbour < shortestPaths[neighbour]) {
13
13
shortestPaths[neighbour] = distanceToNeighbour
14
14
}
15
15
}
16
16
}
17
- return shortestPaths as Array < Int >
17
+ return shortestPaths
18
18
}
You can’t perform that action at this time.
0 commit comments